Skip to content

Non-interactive error tells users to pass --confirm/--no-confirm, which do not exist #1354

Description

@l2ysho

Important

TL;DR — Found this while wondering through codebase, it is corner case but worth of investigation.

Three prompt hooks fall back to a default non-interactive error that tells the user to pass --confirm / --no-confirm:

https://github.com/apify/apify-cli/blob/master/src/lib/hooks/user-confirmations/_stdinCheckWrapper.ts#L27-L46

const ConfirmFlag = 'confirm';
const NoConfirmFlag = `no-${ConfirmFlag}`;
...
errorMessageForStdin = `Please use the --${ConfirmFlag}/--${NoConfirmFlag} flags to confirm the action.`,

Neither flag exists. grep for a confirm flag definition across src/commands/ and src/lib/command-framework/ returns nothing — the two names appear only in that message string. So a user who hits this is told to pass a flag that no command accepts, with no way to proceed.

Where it is reachable

useUserInput and useSelectFromList override the message with something accurate. useYesNoConfirm, useMaskedInput and useInputConfirmation do not, so any call site that also omits providedConfirmFromStdin hits the phantom flags. Two do:

1. useActorConfig — two call sites, neither guarded

useActorConfig is called by init, run, actors/push, actors/pull and actor/calculate-memory. actors/push sets enableJsonFlag, so this is also the one place where --json and a prompt meet today.

Verified repro:

mkdir -p demo/.actor && cd demo
echo '{"name":"old","version":"0.0"}' > apify.json
echo '{"actorSpecification":1,"name":"new","version":"0.0"}' > .actor/actor.json
echo '{"name":"x"}' > package.json

apify run < /dev/null
# Error: Please use the --confirm/--no-confirm flags to confirm the action.

actor calculate-memory < /dev/null
# Error: Please use the --confirm/--no-confirm flags to confirm the action.

No login required — the config check runs before anything else. CI hits the same path via the isCI branch, so this fails a pipeline with an instruction that cannot be followed.

2. auth/login — login.ts:200, the masked token: prompt. Lower impact, since apify login --token <token> is the documented non-interactive path, but the error still names flags that do not exist instead of pointing at --token.

Suggested fix

Pick whichever fits the intended design:

  • Give the three unguarded hooks an accurate default message, the way useUserInput and useSelectFromList already do.
  • Or make the default message generic — "this command needs a terminal; pass the required flags explicitly" — and drop the --confirm naming entirely.
  • Plus thread providedConfirmFromStdin through the useActorConfig call sites so push/run/pull have some way to answer the migration prompt non-interactively.

The login case may just want its own message naming --token.

Notes

Pre-existing on master, not introduced by any open PR. Found while checking how --json and interactive prompts interact across commands.


🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    t-buildersIssues owned by the Builders team.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions