You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PR #15684 — failed hold release leaves an attached Project file TTL-armed (discussion_r3951336169) #12
addChatProjectFile associates a file with a Chat Project through one atomic findOneAndUpdate (capacity guarded), and only afterwards clears the upload hold on the file document:
That ordering is deliberate: a racer that loses the capacity guard must keep its hold so the sweep can reclaim the upload — that is what the reviewed finding asked for. The two writes span two collections without a transaction, so if the release write fails after the association commits, the project keeps the reference while the file keeps expiresAt, a MongoDB-managed one hour TTL (packages/data-schemas/src/schema/file.ts). The request surfaces as a 500 from addProjectFile, and the file can be deleted underneath a project that still lists it.
Why it is not already broken
An idempotent re-add repairs it: the atomic update no-ops, the fresh read finds the file already associated, and the release is retried. The client retries the association on its failed row, so the common path self-heals. A user who never retries keeps a project reference that resolves as unavailable after the TTL fires.
Suggested direction
Compensate the release rather than relying on a retry: a bounded inline retry, or a reconciliation pass that clears holds on files already referenced by a project (the sweep is expiredAt-driven and does not look at project membership). Worth a regression that forces the release write to fail and asserts the file does not stay TTL-armed.
Fixed on dev (852e004): packages/data-schemas/src/methods/chatProject.ts:574-640 releases the hold and restores it via restoreTemporaryHold on failure (d92c40c, LibreChat-AI#15684), so a failed release no longer leaves an attached file TTL-armed.
Activity
berry-13 commentedon Sep 29, 2026
Fixed in the root PR at LibreChat-AI/LibreChat@d92c40c8ce (a failed hold release now fails the attach with nothing attached), verified on head 2f79ee5. Closes when LibreChat-AI#15684 merges.
berry-13 commentedon Oct 8, 2026
Fixed on dev (852e004): packages/data-schemas/src/methods/chatProject.ts:574-640 releases the hold and restores it via restoreTemporaryHold on failure (d92c40c, LibreChat-AI#15684), so a failed release no longer leaves an attached file TTL-armed.