Skip to content

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

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

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. 👍

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant