Skip to content

🧹 fix: Let file deletes succeed when the Code API refuses the sandbox delete - #86

Closed
TomasPalsson wants to merge 1 commit into
sync/v0.8.8-rc4from
fix/delete-missing-local-files
Closed

TomasPalsson wants to merge 1 commit into
sync/v0.8.8-rc4from
fix/delete-missing-local-files

Conversation

@TomasPalsson

Copy link
Copy Markdown

Problem

On vis-prod and apro-prod, users cannot delete agent files whose bytes are gone from /app/uploads. The agent keeps the dead file, and every code turn fails with Failed to provision N file(s) to the code environment.

Datadog (request 465bac5d-…, vis-prod, 2026-10-02 13:37Z):

  1. The local unlink fails with ENOENT. That case is already treated as fine.
  2. The secondary code environment delete returns 409 execution_profile_mismatch (expected default, actual stateful).
  3. createDeleteFileWithSecondaryStorage rethrows that error, so the file goes into failedFileIds. The DB record and the agent references stay.

Fix

The sandbox copy is a cache that expires on its own. A failed code environment delete is now logged as a warning, and the file record and agent references are removed anyway. Vector DB delete failures still block, as before.

Tests

  • New: processDeleteRequest › removes metadata and agent references when the code environment rejects the delete. It fails before this change and passes after.
  • process.spec.js and process.integration.spec.js: 119 passed.
  • routes/files/*.test.js fail to load locally (flowsCache is not a function) with or without this change. That is an environment issue, not this change.

… Sandbox Delete

A file with a code environment reference also deletes its sandbox copy. When the
Code API refused that call (409 execution_profile_mismatch after the switch to a
stateful-only self-hosted Code API), the whole delete was marked failed, so the
record and its agent references stayed and every later code turn aborted with
'Failed to provision N file(s) to the code environment'. The sandbox copy is a
cache that expires on its own, so its delete failure is now logged and ignored.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@TomasPalsson

Copy link
Copy Markdown
Author

Superseded by the upstream fix LibreChat-AI#16671 (narrower: only 409 execution_profile_mismatch is tolerated, in deleteCodeEnvFile). It is cherry-picked onto sync/v0.8.8-rc4 as a single commit.

@TomasPalsson
TomasPalsson deleted the fix/delete-missing-local-files branch October 2, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant