refactor: centralize slug normalization warning in parseOrgProjectArg#436
Merged
refactor: centralize slug normalization warning in parseOrgProjectArg#436
Conversation
Move the slug normalization warning from 5 individual command files into parseOrgProjectArg itself. This ensures every caller gets the warning automatically, including commands that were previously missing it. Changes: - Add warnNormalized() helper in arg-parsing.ts, called internally by parseOrgProjectArg when normalization is applied - Improved message: includes the actual normalized slug value e.g. "Normalized slug to 'my-org/my-project' (Sentry slugs use dashes, never underscores)" - Remove duplicate 3-line warning blocks from event/view, log/view, trace/view, span/list, span/view - Remove now-unused logger.withTag() calls from span/list and span/view Closes #431
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Dsn
Init
Other
Documentation 📚
Internal Changes 🔧Init
Tests
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 111 passed | Total: 111 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1101 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.06% 95.05% -0.01%
==========================================
Files 164 164 —
Lines 22245 22254 +9
Branches 0 0 —
==========================================
+ Hits 21145 21153 +8
- Misses 1100 1101 +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.
Summary
Moves the slug normalization warning from 5 individual command files into
parseOrgProjectArg()itself. Every caller now gets the warning automatically — no per-command boilerplate, and no risk of future commands forgetting it.Changes
src/lib/arg-parsing.ts— core change:warnNormalized()helper that builds a display slug from theParsedOrgProjectvariantparseOrgProjectArg()to emit the warning internally before returningNormalized slug to 'my-org/my-project' (Sentry slugs use dashes, never underscores)5 command files — removed duplicate 3-line if-blocks:
src/commands/event/view.tssrc/commands/log/view.tssrc/commands/trace/view.tssrc/commands/span/list.ts(also removed now-unusedlogger.withTag())src/commands/span/view.ts(also removed now-unusedcmdLogvariable)test/lib/arg-parsing.test.ts— 6 new tests:project-search,explicit(org/project),org-allauto-detector non-underscored slugsBefore / After
Before — copy-pasted in every command:
After — callers just call the parser:
Test Plan
bun run typecheck— passesbun run lint— passes (0 errors)bun test test/lib/arg-parsing.test.ts— 106 tests passgit grep 'Sentry slugs use dashes' -- 'src/'— only matchesarg-parsing.tsCloses #431