Skip to content

feat!: reject IDs that cannot be part of a key-value store key - #2548

Merged
vdusek merged 2 commits into
v2from
validate-crawler-id
Nov 30, 2026
Merged

vdusek merged 2 commits into
v2from
validate-crawler-id

Conversation

@vdusek

@vdusek vdusek commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

The id of a crawler is now checked, so it can always be part of a key-value store key. The same check runs for an explicit id of SessionPool, Statistics and DefaultRenderingTypePredictor, which use it in their keys too.

  • The id must be at most 217 characters long and contain only a-zA-Z0-9!-_.'(), otherwise the constructor raises ValueError. The limit leaves room for the longest key prefix, CRAWLEE_RENDERING_TYPE_PREDICTOR_STATE_ (39 characters), within the 256-character key limit. Crawlee JS checks the same characters but allows 256, so its derived keys can be longer than a valid key.
  • A non-string id, such as an int from v1, raises TypeError that names the class.

Before, an id like a/b produced keys like CRAWLEE_STATE_a/b, which the Apify platform doesn't accept as keys.

It's breaking, since an id that worked before can now raise. The new check replaces the first half of test_id_invalid_as_request_queue_alias, because an id that passes it always forms a valid RQ alias. The second half is kept as its own test.

Closes: #2546

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 30, 2026
@vdusek vdusek self-assigned this Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v2@99fc497). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff          @@
##             v2    #2548   +/-   ##
=====================================
  Coverage      ?   95.56%           
=====================================
  Files         ?      196           
  Lines         ?    15528           
  Branches      ?        0           
=====================================
  Hits          ?    14840           
  Misses        ?      688           
  Partials      ?        0           
Flag Coverage Δ
integration 75.39% <63.63%> (?)
unit 89.79% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek changed the title feat(crawlers)!: reject a crawler id that is not a valid key feat!: reject IDs that can't be part of a key-value store key Nov 30, 2026
@vdusek vdusek changed the title feat!: reject IDs that can't be part of a key-value store key feat!: reject IDs that cannot be part of a key-value store key Nov 30, 2026
@vdusek
vdusek marked this pull request as ready for review November 30, 2026 12:44
@vdusek
vdusek requested a review from Mantisus November 30, 2026 12:44

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@apify-approval-mirror apify-approval-mirror Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mirroring approval from @Mantisus.

@vdusek
vdusek merged commit 180dd95 into v2 Nov 30, 2026
46 checks passed
@vdusek
vdusek deleted the validate-crawler-id branch November 30, 2026 13:02
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