Repository navigation
fix(storage)!: take upsert as a bool in upload and create_signed_upload_url - #1997
Conversation
…ad_url BREAKING CHANGE: upload() and create_signed_upload_url() now take upsert as a bool instead of a string. update() no longer accepts upsert, since it was never sent.
|
No actionable comments were generated in the recent review. Summary
Change: Bug fix · Severity of issue fixed: Medium Merge Risk:
|
What
The storage upload methods took
upsertas a string and copied it straight into thex-upsertheader. This PR types it as abool, in line with storage-js (upsert?: boolean).upload():upsert: bool = False, sent asx-upsert: trueorx-upsert: false.create_signed_upload_url():upsert: bool | None = None. The header is only sent when the argument is set, so the server default still applies when it is omitted. Passingupsert=Falsenow sendsx-upsert: falseinstead of being dropped.update(): theupsertargument is removed.update()usesPUT, which never sent the header, so the argument did nothing.boolupsertraisesTypeError. Without this check, a leftoverupsert="false"would be truthy and be sent asx-upsert: true, overwriting files silently.MIGRATION.mdgets a section on the storageupsertchange.Why
upsert=Truefailed inside httpx withTypeError: Header value must be str or bytes, not <class 'bool'>."True"or"yes"were sent unchanged and could silently fail to overwrite.Breaking change
upsert="true"orupsert="false"must passTrueorFalse.upsert=toupdate()must remove it.This targets
main(v3) only.Tests
Added unit tests for the
x-upsertheader value ofupload()andcreate_signed_upload_url(), and for theTypeErroron a stringupsert, for both the sync and async clients.Closes #1996