Skip to content

fix(opencode): output error message before help in .fail() handler#31488

Open
Btocode wants to merge 1 commit into
anomalyco:devfrom
Btocode:fix/cli-fail-swallows-error-msg
Open

fix(opencode): output error message before help in .fail() handler#31488
Btocode wants to merge 1 commit into
anomalyco:devfrom
Btocode:fix/cli-fail-swallows-error-msg

Conversation

@Btocode

@Btocode Btocode commented Jun 9, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #29390

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When passing an invalid argument like --unknown-flag, the .fail() handler in yargs was calling cli.showHelp(show) but never output the error message msg to stderr. This meant the user saw the same output as --help with no indication of what they did wrong.

The fix writes the error message to stderr before showing the help text, so the user sees e.g. "Unknown argument: --unknown-flag" followed by the help output.

How did you verify your code works?

  • Inspected the code to confirm msg contains the error string and EOL is already imported
  • The change is a single line that follows the same pattern used elsewhere in the file (process.stderr.write(...))

Screenshots / recordings

N/A — CLI change only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

I found two related PRs that appear to address the same issue:

  1. fix(opencode): show CLI failure message before help #31228 - fix(opencode): show CLI failure message before help

  2. fix(opencode): show error message in CLI .fail() handler #29393 - fix(opencode): show error message in CLI .fail() handler

Both PRs appear to be fixing the same issue: ensuring error messages are displayed to the user before or instead of the help text when invalid arguments are passed. PR #31228 seems to be the most recent attempt at this fix with very similar wording to the current PR #31488.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

fix(opencode): CLI .fail() handler swallows error message

1 participant