Skip to content

fix: do not surface hidden options in implications error (#2540) - #2587

Closed
shehjaddev wants to merge 1 commit into
yargs:mainfrom
shehjaddev:fix/hidden-implies-leak
Closed

shehjaddev wants to merge 1 commit into
yargs:mainfrom
shehjaddev:fix/hidden-implies-leak

Conversation

@shehjaddev

Copy link
Copy Markdown

Summary

yargs.implications() (used by .implies()) currently includes the names of hidden options in its "Implications failed" error. Hidden options are marked hidden: true precisely so they stay out of user-facing output (help, completion), so leaking their names in a validation error is a bug. Reported in #2540.

Reproduction

yargs(['--remote-debugging-port', '9222'])
  .option('hidden-debug', {type: 'boolean', hidden: true})
  .option('remote-debugging-port', {hidden: true})
  .implies('remote-debugging-port', 'hidden-debug')
  .parse();

Before this change, the failure message was:

Implications failed:
 remote-debugging-port -> hidden-debug

disclosing both internal option names.

Fix

In lib/validation.ts, self.implications() now skips any implication where either the key or the value is a hidden option, using the same yargs.getOptions().hiddenOptions source of truth that help and completion already use. Hidden options are internal, so they should not produce (or appear in) user-facing validation errors.

Test

Added a regression test in test/validation.mjs asserting that an implication involving only hidden options does not surface their names (and raises no error).

npm test passes — 833 passing, lint clean.

Hidden options are internal and should not be disclosed in user-facing validation errors. Skip implications where either the key or value is a hidden option, matching how hidden options are already excluded from help and completion. Fixes #2540
@shehjaddev
shehjaddev force-pushed the fix/hidden-implies-leak branch from 730b5cb to 7f0ce3d Compare September 3, 2026 14:00
@shehjaddev shehjaddev closed this Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant