Skip to content

apify create --no-optional is silently ignored #1349

Description

@MatousMarik

The omit-optional-deps flag of apify create registers no-optional as an alias (src/commands/create.ts):

'omit-optional-deps': Flags.boolean({
    aliases: ['no-optional'],
    ...
}),

But the command parser runs node:util parseArgs with allowNegative: true, which rewrites --no-optional into a negation of optional before alias matching happens:

parseArgs({ args: ['--no-optional'], options: { 'omit-optional-deps': {...}, 'no-optional': {...} }, allowNegative: true })
// => { values: { optional: [false] } }

optional matches neither omit-optional-deps nor the no-optional alias in _parseFlags, so omitOptionalDeps stays undefined--no-optional is accepted without error and optional dependencies get installed anyway. --omit-optional-deps works fine.

Likely broken since the migration from yargs to node:util parseArgs (yargs treated --no-optional as the literal alias). Possible fixes: rename the alias to something without the no- prefix, special-case negation-shadowed aliases in the parser, or drop the alias.

Found while working on #1345.

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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions