Skip to content

Python HL SDK: use IfNoneMatch to support conditional write (aka exclusive creation) #9309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

skshetry
Copy link
Contributor

Change Description

Closes #7505.

This replaces existing obj.exists() check with conditional writes using 'IfNoneMatch: *'. I have tried to maintain compat in terms of error raised, by raising ObjectExistsError on pre-condition failure.

Testing Details

How were the changes tested?

There is an existing test_object_upload_exists that covers this. I have extended this test by parametrizing it with pre_sign=True|False.

Breaking Change?

Does this change break any existing functionality? (API, CLI, Clients)

No.

Additional info

Logs, outputs, screenshots of changes if applicable (CLI / GUI changes)

Contact Details

How can we get in touch with you if we need more info? (ex. [email protected])

@skshetry skshetry force-pushed the fix/exclusive-file-create-mode branch from cf6c55f to 32a69f9 Compare July 17, 2025 13:50
…usive creation)

Closes treeverse#7505.

This replaces existing obj.exists() check with conditional writes with 'IfNoneMatch: *'.
I have tried to maintain compat in terms of error raised, by raising `ObjectExistsError` on pre-condition failure.
@skshetry skshetry force-pushed the fix/exclusive-file-create-mode branch from 32a69f9 to e69ea94 Compare July 17, 2025 13:52
@skshetry skshetry marked this pull request as draft July 17, 2025 14:12
@skshetry skshetry marked this pull request as ready for review July 21, 2025 04:40
@itaiad200 itaiad200 requested review from nopcoder and N-o-Z July 22, 2025 08:07
Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, had a small comment related to a check in the code.
Also, if you can open a follow-up issues:

  • Refactor: the exception handling should use api_exception_handler with customer handler to address the specific if_none_match. This should align all the exceptions thrown based on the API to the SDK exception
  • Bug: it seems we have a resource leak while exception is thrown calling close and the upload/link throws an exception we continue to raise without closing the fd.

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.

Python high level SDK: support mode="x"
2 participants