fix(task): support raw task IDs in task run - #1388
Open
kuntal1461 wants to merge 1 commit into
Open
Conversation
Use APIFY_ID_REGEX from @apify/consts to detect a raw Apify resource ID and attempt a direct client.task(id) lookup before falling back to the existing username/name path. Normal task names skip the extra lookup. git commit -F /tmp/commit_msg.txt
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.
Fixes #1360
Problem
apify task run <rawId>fails with "Cannot find Task with name …" for any raw Apify task ID. TheresolveTaskIdmethod has only two branches:/→ use as-is (username/task-name)/→ always prepend the authenticated username →username/rawId→ 404The argument description has always read
"Name or ID of the Task to run (e.g. 'my-task' or 'E2jjCZBezvAZnX8Rb')". The ID half has never worked.The identical bug was fixed for
apify callinffb0b7c3(fix(call): support calling with bare ids) but was never applied totask run.Fix
Import
APIFY_ID_REGEXfrom@apify/consts(already in the dependency tree) and use it as a gate before the name-based fallback:Normal task names containing hyphens (e.g.
my-task) do not matchAPIFY_ID_REGEXand skip the new path entirely — zero extra API calls for existing usage.Changes
src/commands/task/run.ts— addAPIFY_ID_REGEXimport and raw-ID lookup path inresolveTaskId; update error message to"name or ID"(consistent withactors/call.ts:315)test/api/commands/task/run.test.ts— capturerawTaskId = task.idinbeforeAll; add'should work with just the task ID'test caseBehaviour matrix
yRWwqZmoMTLdEoMOI(raw ID)my-task(bare name)username/my-task(qualified)Install size
No new package.
APIFY_ID_REGEXis an additional named import from@apify/consts, which is already in the dependency tree.Out of scope
task publishandtask unpublishcarry the same pattern but their documented contract lists names only — tracked separately.