Skip to content

fix: enforce strict APIFY_ID_REGEX validation with anchors#640

Merged
jancurn merged 1 commit into
masterfrom
claude/revert-strict-regex-idbaU
May 22, 2026
Merged

fix: enforce strict APIFY_ID_REGEX validation with anchors#640
jancurn merged 1 commit into
masterfrom
claude/revert-strict-regex-idbaU

Conversation

@jancurn
Copy link
Copy Markdown
Member

@jancurn jancurn commented May 21, 2026

Restores APIFY_ID_REGEX to the anchored form /^[a-zA-Z0-9]{17}$/ (resolving the long-standing TODO) and adds test coverage for inputs that only the anchored regex rejects: 18+ char strings, embedded 17-char matches, and the empty string.

https://claude.ai/code/session_01Eay2aTeQ79xWdQguqE6n27

Seems we forgot to properly fix this old ducktape. I asked Claude to research uses of APIFY_ID_REGEX in apify-core and it says it's safe. User yZtyxMUADJHyInTIdl is completely deleted, and there are no others with incorrect ID in the database.

There are a few other places where this constant is used, but it looks safe: https://github.com/search?q=org%3Aapify+%22APIFY_ID_REGEX%22&type=code

The regex was loosened as a temporary workaround to keep an 18-char
legacy user (yZtyxMUADJHyInTIdl) flagged as forbidden via
isForbiddenUsername. That user has since been deleted, so the anchors
can be restored. Strict regex prevents arbitrary strings containing a
17-char alphanumeric substring from being incorrectly treated as Apify
IDs.

Added tests for the anchored behaviour: 18+ char alphanumeric strings,
strings with valid 17-char IDs embedded in larger strings, and the
empty string are now explicitly rejected.
@jancurn jancurn changed the title fix: enforce strict APIFY_ID_REGEX validation with anchors [WIP] fix: enforce strict APIFY_ID_REGEX validation with anchors May 21, 2026
@jancurn jancurn changed the title [WIP] fix: enforce strict APIFY_ID_REGEX validation with anchors [DO NOT MERGE] fix: enforce strict APIFY_ID_REGEX validation with anchors May 22, 2026
@jancurn jancurn changed the title [DO NOT MERGE] fix: enforce strict APIFY_ID_REGEX validation with anchors [DO NOT MERGE] fix: enforce strict APIFY_ID_REGEX validation with anchors May 22, 2026
@jancurn jancurn changed the title [DO NOT MERGE] fix: enforce strict APIFY_ID_REGEX validation with anchors fix: enforce strict APIFY_ID_REGEX validation with anchors May 22, 2026
@jancurn jancurn requested review from B4nan, fnesveda and mtrunkat May 22, 2026 09:04
@jancurn jancurn merged commit b46f967 into master May 22, 2026
12 of 17 checks passed
@jancurn jancurn deleted the claude/revert-strict-regex-idbaU branch May 22, 2026 10:14
jancurn pushed a commit that referenced this pull request May 22, 2026
After #640 the constant is anchored at the source, so the mongo-check
example no longer needs to explain why we deviate from it.
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.

6 participants