Repository navigation
PYTHON-6299 Reject non-string filename in GridFSBucket delete_by_name… - #3262
Open
MaddipatlaChetan24 wants to merge 1 commit into
Open
MaddipatlaChetan24 wants to merge 1 commit into
MaddipatlaChetan24 wants to merge 1 commit into
Conversation
… and rename_by_name
PYTHON-6183 made GridFS.get_version and get_last_version reject a
non-string filename, because a dict was used as query criteria.
GridFSBucket.delete_by_name and rename_by_name had the same problem:
delete_by_name({"$ne": None}) matched and deleted every file in the
bucket. Validate filename (and new_filename) the same way
open_download_stream_by_name already does.
This branch has not been deployed
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.
PYTHON-6299
Changes in this PR
GridFSBucket.delete_by_nameandrename_by_namepassedfilenamestraight into the files query, so a dict was used as query criteria:delete_by_name({"$ne": None})deleted every file in the bucket. This adds the samevalidate_stringcheck thatopen_download_stream_by_namealready does (and that PYTHON-6183 added toGridFS.get_version), and also validatesnew_filenameinrename_by_name. Sync files regenerated with synchro.Test Plan
Added
test_delete_by_name_invalid_filenameandtest_rename_by_name_invalid_filename(async and sync). They check that a dict raises TypeError and that no file is deleted or renamed.Checklist
Checklist for Author
AI disclosure: I used an AI assistant to help find this and draft the change. I reviewed every line, understand the fix, and will handle review myself.