fix: recover no-* boolean aliases swallowed by parseArgs allowNegative (#1349) - #1381
Open
kuntal1461 wants to merge 1 commit into
Open
fix: recover no-* boolean aliases swallowed by parseArgs allowNegative (#1349)#1381kuntal1461 wants to merge 1 commit into
kuntal1461 wants to merge 1 commit into
Conversation
Node.js parseArgs with allowNegative:true intercepts --no-X before the options table lookup, storing rawFlags['X'] = false instead of rawFlags['no-X'] = true. This caused apify create --no-optional to be silently ignored: _parseFlags checked for 'no-optional' in rawFlags, found nothing, and left omitOptionalDeps undefined, so optional deps always installed regardless of the flag. Fix: after the allMatchers lookup, scan any no-* aliases and check whether their stripped positive name is stored as false in rawFlags. If found, set rawFlag = true so the rest of the boolean parsing path proceeds normally. Fixes apify#1349
kuntal1461
force-pushed
the
fix/1349-no-optional-silently-ignored
branch
from
September 2, 2026 13:07
b6281ea to
52d4d4a
Compare
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.
Problem
apify create --no-optionalwas silently ignored — optional deps always installed regardless of the flag.Root cause: Node.js
parseArgswithallowNegative: trueintercepts any--no-Xtoken before consulting the options table. For--no-optional, it strips the prefix and storesrawFlags['optional'] = false(even thoughoptionalis not a registered option). The registration ofno-optionalas a direct boolean option passes thestrict: truevalidity check, but the value never lands under that key._parseFlagsthen checksallMatchers = ['omit-optional-deps', 'no-optional']againstrawFlags, finds neither key, and leavesomitOptionalDepsundefined.Empirically confirmed with Node.js 24.19.0:
Fix
Single insertion in
_parseFlags(src/lib/command-framework/apify-command.ts): after theallMatcherslookup finds nothing, scan eachno-*alias and check whether its stripped positive name is present inrawFlagswith valuefalse. If so, setrawFlag = trueso the rest of the boolean-parsing path proceeds normally.flags.tsis unchanged -- theno-optionalregistration must stay sostrict: truedoes not throw when--no-optionalis passed.create.tsis unchanged --aliases: ['no-optional']is now correctly recovered.no-*alias gets the same treatment automatically.Testing
pnpm exec vitest run test/local/commands/create.test.ts).pnpm run build), lint+format pass (enforced by pre-commit hook).Fixes #1349