fix(codeapi): answer 404 on delete of an absent object without ownership record - #245
Open
Shabonasar wants to merge 1 commit into
Open
Shabonasar wants to merge 1 commit into
Shabonasar wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sessionAuthanswers 403 toDELETE /files/:session_id/:fileIdwhenever ownership cannot be established. For sessions that predate the durablesession-owner:*record (reasonunknown) this can never succeed, so a client sweeping its retention window keeps retrying the same DELETE for an object the bucket has long since dropped.With this change a DELETE that fails authorization first asks the file-server for the object's metadata. If the object is absent, the route answers 404, which is what
deleteSessionObjectalready returns for an absent object once authorized, and what LibreChat'sdeleteCodeEnvFiletreats as "already gone". If the object still exists, the response stays 403.Downloads and metadata reads are untouched: the check runs only for DELETE and only after ownership was denied.
Observed
After upgrading a deployment whose sessions were created before
session-ownerexisted, LibreChat loggedError deleting file Request failed with status code 403on every retention sweep (100 per pass) while codeapi loggedUnauthorized delete: Cached session key: null | ... | Reason: unknown. The objects had already been removed by the bucket lifecycle.rehydrate-session-cacherestores such sessions, but it needs a manifest and a manual run, while the records keep going into backoff until then.Test plan