Repository navigation
fix: Reject empty resource IDs in the resource client getters - #1261
Closed
pcbeingused333 wants to merge 1 commit into
Closed
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
An empty ID failed only on the first request, and `client.user('')` fell back to `me`, silently reading the token owner's account.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
|
Closing, #1178 is milestoned for v4, because rejecting an empty ID when the getter is called is a breaking change. |
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.
Part of #1178.
client.user('')did not fail:UserClientusedresource_id or 'me', so an empty value (for example from an unset environment variable) silently read the token owner's account. Other getters accepted an empty ID and only failed on the first request, with an error about URL path segments.Changes:
ResourceClientBaseraisesValueErrorfor an emptyresource_id, so root and nested getters (sync and async) fail when called. The message namesresource_idand the resource path.UserClient/UserClientAsyncfall back tomeonly when the ID isNone.This is a behavior change for code that built a client with an empty ID and never sent a request: it now raises at the getter.
Not covered here: the checks for negative client options and
limit/offsetfrom the same issue.Tests: new
tests/unit/test_empty_resource_id.py. The empty case was removed fromtest_degenerate_resource_id_is_rejected_before_the_request, since it no longer reaches the request.Drafted with AI assistance (Claude Code).