Description
apify call -i '<valid JSON object>' fails with
Error: Providing a JSON file path in the --input flag is not supported. Use the "--input-file=" flag instead
whenever the JSON string contains a ~ character anywhere — even though the value is a well-formed inline JSON object, not a path. Since Actor ids use the username~actor-name format, any input that references another Actor by id triggers this (a common pattern, e.g. telling one Actor which Standby Actor to call).
Steps to reproduce
apify call my-actor --input '{"standbyActorId": "some-user~some-actor"}'
Actual:
Error: Providing a JSON file path in the --input flag is not supported. Use the "--input-file=" flag instead
Expected: the value parses as inline JSON and the call proceeds (removing the ~ from the string makes it work).
Root cause
src/lib/commands/resolve-input.ts — the path heuristic runs before any JSON parse attempt, and the home-directory check matches ~ anywhere in the string:
const inputLooksLikePath =
// JSON file
inputFlag.endsWith('.json') ||
inputFlag.endsWith('.json5') ||
// UNIX-style path access
// this also matches Windows paths
path.isAbsolute(inputFlag) ||
inputFlag.startsWith('./') ||
inputFlag.startsWith('../') ||
// Home directory access
inputFlag.includes('~') || // <-- matches inside JSON string values
// Windows-style path access
inputFlag.startsWith('.\\') ||
inputFlag.startsWith('..\\');
if (fileExists || inputLooksLikePath) {
error({
message: `Providing a JSON file path in the --input flag is not supported. Use the "--input-file=" flag instead`,
});
...
}
(observed at master @ bcdafba, reproduced with apify-cli 1.7.2)
Suggested fix
Either (or both):
- A home-directory path is only meaningful when the value starts with
~ — change inputFlag.includes('~') to inputFlag.startsWith('~').
- Skip the path heuristic entirely when the trimmed value starts with
{ (an object is the only accepted inline shape anyway), or attempt JSON.parse first and only fall through to the path checks when parsing fails.
Workaround
Use --input-file:
echo '{"standbyActorId": "some-user~some-actor"}' > input.json
apify call my-actor --input-file=input.json
Environment
- apify-cli 1.7.2, Node 22, Linux
Description
apify call -i '<valid JSON object>'fails withwhenever the JSON string contains a
~character anywhere — even though the value is a well-formed inline JSON object, not a path. Since Actor ids use theusername~actor-nameformat, any input that references another Actor by id triggers this (a common pattern, e.g. telling one Actor which Standby Actor to call).Steps to reproduce
apify call my-actor --input '{"standbyActorId": "some-user~some-actor"}'Actual:
Expected: the value parses as inline JSON and the call proceeds (removing the
~from the string makes it work).Root cause
src/lib/commands/resolve-input.ts— the path heuristic runs before any JSON parse attempt, and the home-directory check matches~anywhere in the string:(observed at
master@bcdafba, reproduced with apify-cli 1.7.2)Suggested fix
Either (or both):
~— changeinputFlag.includes('~')toinputFlag.startsWith('~').{(an object is the only accepted inline shape anyway), or attemptJSON.parsefirst and only fall through to the path checks when parsing fails.Workaround
Use
--input-file:Environment