fix(api): warn when endpoint contains "?" to prevent silent shell truncation#1264
Draft
DaveHanns wants to merge 1 commit into
Draft
fix(api): warn when endpoint contains "?" to prevent silent shell truncation#1264DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
…ncation
Running `apify api /v2/acts?my=1&limit=100` from an unquoted shell backgrounds
the command at `&` and passes only `/v2/acts?my=1` to the CLI. The rest is
silently dropped and the request returns something the caller did not ask for.
The CLI can never see the `&` (the shell consumed it), but the leftover `?` in
the endpoint is a strong signal that inline query parameters were intended. Emit
a stderr warning in that case with two concrete fixes:
apify api /v2/acts -p '{"my":1,"limit":100}'
apify api '/v2/acts?my=1&limit=100'
Also mention this in the command description so `--help` teaches the same thing.
Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Running
apify apiwith an unquoted endpoint that contains a query string is silently truncated by the shell, so the CLI ends up hitting a different URL than the user intended. This PR detects the tell-tale?in the endpoint arg and emits a stderr warning pointing at two safe forms.Reproducer
$ apify api /v2/acts?my=1&limit=100The shell interprets
&as the background operator, so the CLI process only receives/v2/acts?my=1inargv;limit=100is discarded. The request returns a much larger response than the caller expected (nolimit), and there is no indication that anything was dropped. In practice this pushes users (and agents) to abandonapify apiand fall back to rawcurl, e.g.:?on its own can also be expanded by the shell as a glob if a matching filename happens to exist in the current directory.Fix
The CLI cannot see the missing
&(the shell consumed it beforeexecve), but the leftover?in the endpoint is a strong signal that inline query parameters were being passed. When the endpoint contains?, print a stderr warning with two concrete fixes:The warning is stderr-only and does not change exit code or behavior, so this is fully backward-compatible for callers who already quote correctly. The same guidance is added to the command description so
apify api --helpteaches it too.Test plan
apify api /v2/acts?my=1&limit=100(unquoted) — stderr warning shown, request still proceeds.apify api '/v2/acts?my=1&limit=100'— warning shown (same signal, same guidance), request proceeds correctly.apify api /v2/users/me— no warning.apify api /v2/acts -p '{"my":1,"limit":100}'— no warning; recommended form.pnpm test test/local/commands/api.test.ts— new coverage indescribe('inline query-string detection', ...)plus all existing api tests still pass (27/27).pnpm run update-docs—docs/reference.mdregenerated from the updated description; no stale content.Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.