Skip to content

fix(api): auto-correct ':' to '=' in --field values with a warning#302

Merged
BYK merged 1 commit intomainfrom
fix/api-field-colon-autocorrect
Feb 26, 2026
Merged

fix(api): auto-correct ':' to '=' in --field values with a warning#302
BYK merged 1 commit intomainfrom
fix/api-field-colon-autocorrect

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 26, 2026

Problem

Two production errors (CLI-9H, CLI-93) share the same root cause: users pass --field values using : as the separator instead of =, matching Sentry search-query syntax instincts.

  • sentry api .../issues/ -X PUT -F project:4510942921490432 -F status:resolved
  • sentry api .../issues/.../stats/ -F since:2026-02-25T11:20:00

Both crashed immediately with Invalid field format: … Expected key=value — correct but unhelpful, and a hard failure either way.

Solution

Auto-correct and warn instead of crash, following the established pattern for recoverable user mistakes.

  • Added normalizeFields(fields, stderr) that rewrites key:valuekey=value and prints a warning to stderr when a field has no =. Splitting on the first : preserves colons inside values (ISO timestamps, URLs with ports).
  • Correction only fires when there is no = at all — the request would crash anyway, so there is no ambiguity.
  • Parsers stay pure; normalization happens at the command level in func() before prepareRequestOptions(), covering both body and query-param paths.
  • Upgraded bare throw new Error sites in the field parsers to throw new ValidationError for clean central error handling.

Testing

11 new unit tests for normalizeFields (pass-through, colon-correction, timestamp/URL values, mixed fields, edge cases). 3 existing error tests updated to assert ValidationError type. Full suite: 2082 pass, 0 fail.

Fixes CLI-9H
Fixes CLI-93

When users pass --field values using ':' as the separator (e.g.
`-F status:resolved`), auto-correct to '=' and print a warning to
stderr instead of crashing. Splits on the first ':' so values that
contain colons (ISO timestamps, URLs) are preserved intact.

Also upgrades the remaining bare `throw new Error` sites in the field
parsers to `throw new ValidationError` for clean central error handling.

Fixes CLI-9H
Fixes CLI-93
@github-actions
Copy link
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (api) Auto-correct ':' to '=' in --field values with a warning by BYK in #302
  • (ci) Generate JUnit XML to silence codecov-action warnings by BYK in #300
  • (nightly) Push to GHCR from artifacts dir so layer titles are bare filenames by BYK in #301

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

Codecov Results 📊

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

All tests are passing successfully.

✅ Patch coverage is 85.42%. Project has 3608 uncovered lines.
✅ Project coverage is 76.47%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
api.ts 90.36% ⚠️ 48 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    76.42%    76.47%    +0.05%
==========================================
  Files          117       117         —
  Lines        15298     15335       +37
  Branches         0         0         —
==========================================
+ Hits         11691     11727       +36
- Misses        3607      3608        +1
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review February 26, 2026 21:21
@BYK BYK merged commit 1bbc0db into main Feb 26, 2026
20 checks passed
@BYK BYK deleted the fix/api-field-colon-autocorrect branch February 26, 2026 21:33
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