Skip to content

fix(init): replace confusing classifyArgs errors with specific ValidationError messages#979

Merged
betegon merged 1 commit into
mainfrom
fix/init-classifyargs-error-messages
May 19, 2026
Merged

fix(init): replace confusing classifyArgs errors with specific ValidationError messages#979
betegon merged 1 commit into
mainfrom
fix/init-classifyargs-error-messages

Conversation

@betegon

@betegon betegon commented May 19, 2026

Copy link
Copy Markdown
Member

classifyArgs was throwing ContextError for two invalid-input cases, which produced the nonsensical headline "Arguments is required." The root cause ("Two targets provided") was buried in the "Or:" alternatives section — exactly where a user's eye goes last.

Three problems fixed:

  • Wrong error class. ContextError is for missing required values. These are invalid-input cases → ValidationError.
  • Meaningless headline. ContextError("Arguments", ...)"Arguments is required." makes no sense when the user did provide args.
  • Diagnosis buried. The actual explanation was an "Or:" bullet instead of the lead line.

Before (e.g. sentry init acme/ other/):

Arguments is required.

Specify it using:
  sentry init <org>/<project> [directory]

Or:
  - Two targets provided. Use <org>/<project> for the target and a path (e.g., ./dir) for the directory.

After:

"acme/" and "other/" are both treated as targets — only one is allowed.

Pair a target with a directory path:
  sentry init acme/ ./my-project

Closes https://sentry.sentry.io/issues/7485819399/

…tionError messages

ContextError was the wrong class — it's for missing required values, not
invalid input. The generated headline "Arguments is required." was nonsensical
when the user had already provided args. The actual diagnosis was buried in the
"Or:" section instead of leading the message.

Switches both error cases to ValidationError and echoes back exactly what the
user typed so they can see why each argument was misclassified.

Closes https://sentry.sentry.io/issues/7485819399/

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@betegon betegon marked this pull request as ready for review May 19, 2026 11:29
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-979/

Built to branch gh-pages at 2026-05-19 11:29 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

6986 passed | Total: 6986 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 14204 uncovered lines.
❌ Project coverage is 77.04%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    77.08%    77.04%    -0.04%
==========================================
  Files          320       320         —
  Lines        61802     61852       +50
  Branches         0         0         —
==========================================
+ Hits         47636     47648       +12
- Misses       14166     14204       +38
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon enabled auto-merge (squash) May 19, 2026 11:30
@betegon betegon merged commit a80bb0f into main May 19, 2026
28 checks passed
@betegon betegon deleted the fix/init-classifyargs-error-messages branch May 19, 2026 11:34
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