fix(api): auto-correct ':' to '=' in --field values with a warning#302
Merged
fix(api): auto-correct ':' to '=' in --field values with a warning#302
Conversation
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
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
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. Files with missing lines (1)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two production errors (CLI-9H, CLI-93) share the same root cause: users pass
--fieldvalues using:as the separator instead of=, matching Sentry search-query syntax instincts.sentry api .../issues/ -X PUT -F project:4510942921490432 -F status:resolvedsentry api .../issues/.../stats/ -F since:2026-02-25T11:20:00Both 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.
normalizeFields(fields, stderr)that rewriteskey:value→key=valueand prints a warning to stderr when a field has no=. Splitting on the first:preserves colons inside values (ISO timestamps, URLs with ports).=at all — the request would crash anyway, so there is no ambiguity.func()beforeprepareRequestOptions(), covering both body and query-param paths.throw new Errorsites in the field parsers tothrow new ValidationErrorfor 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 assertValidationErrortype. Full suite: 2082 pass, 0 fail.Fixes CLI-9H
Fixes CLI-93