Skip to content

fix: Reject empty resource IDs in the resource client getters - #1261

Closed
pcbeingused333 wants to merge 1 commit into
apify:masterfrom
pcbeingused333:fix/reject-empty-resource-id
Closed

pcbeingused333 wants to merge 1 commit into
apify:masterfrom
pcbeingused333:fix/reject-empty-resource-id

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Part of #1178.

client.user('') did not fail: UserClient used resource_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:

  • ResourceClientBase raises ValueError for an empty resource_id, so root and nested getters (sync and async) fail when called. The message names resource_id and the resource path.
  • UserClient / UserClientAsync fall back to me only when the ID is None.

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 / offset from the same issue.

Tests: new tests/unit/test_empty_resource_id.py. The empty case was removed from test_degenerate_resource_id_is_rejected_before_the_request, since it no longer reaches the request.

Drafted with AI assistance (Claude Code).

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>
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 27, 2026
@vdusek

vdusek commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Closing, #1178 is milestoned for v4, because rejecting an empty ID when the getter is called is a breaking change.

@vdusek vdusek closed this Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants