Skip to content

refactor: centralize slug normalization warning in parseOrgProjectArg#436

Merged
BYK merged 1 commit intomainfrom
refactor/431-slug-normalization-helper
Mar 16, 2026
Merged

refactor: centralize slug normalization warning in parseOrgProjectArg#436
BYK merged 1 commit intomainfrom
refactor/431-slug-normalization-helper

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 16, 2026

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:

  • Added private warnNormalized() helper that builds a display slug from the ParsedOrgProject variant
  • Restructured parseOrgProjectArg() to emit the warning internally before returning
  • Improved message now includes the actual normalized value:
    Normalized 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.ts
  • src/commands/log/view.ts
  • src/commands/trace/view.ts
  • src/commands/span/list.ts (also removed now-unused logger.withTag())
  • src/commands/span/view.ts (also removed now-unused cmdLog variable)

test/lib/arg-parsing.test.ts — 6 new tests:

  • Warning emitted for each variant: project-search, explicit (org/project), org-all
  • No warning for auto-detect or non-underscored slugs

Before / After

Before — copy-pasted in every command:

const parsed = parseOrgProjectArg(targetArg);
if (parsed.type !== "auto-detect" && parsed.normalized) {
  log.warn("Normalized slug (Sentry slugs use dashes, not underscores)");
}

After — callers just call the parser:

const parsed = parseOrgProjectArg(targetArg);
// Warning emitted automatically inside parseOrgProjectArg

Test Plan

  • bun run typecheck — passes
  • bun run lint — passes (0 errors)
  • bun test test/lib/arg-parsing.test.ts — 106 tests pass
  • git grep 'Sentry slugs use dashes' -- 'src/' — only matches arg-parsing.ts

Closes #431

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
@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).


New Features ✨

Init

  • Show feedback hint after successful setup by betegon in #430
  • Add --team flag to relay team selection to project creation by MathurAditya724 in #403
  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Issue List

  • Auto-compact when table exceeds terminal height by BYK in #395
  • Redesign table to match Sentry web UI by BYK in #372

Other

  • (auth) Allow re-authentication without manual logout by BYK in #417
  • (trial) Auto-prompt for Seer trial + sentry trial list/start commands by BYK in #399
  • Add --json flag to help command for agent introspection by BYK in #432
  • Add sentry span list and sentry span view commands by betegon in #393
  • Support SENTRY_HOST as alias for SENTRY_URL by betegon in #409
  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Dsn

Init

  • Align multiselect hint lines with clack's visual frame by MathurAditya724 in #435
  • Make URLs clickable with OSC 8 terminal hyperlinks by MathurAditya724 in #423
  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • (trace) Show span IDs in trace view and fix event_id mapping by betegon in #400
  • Show human-friendly names in trial list and surface plan trials by BYK in #412
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Documentation 📚

  • Update AGENTS.md with patterns from span commands work by BYK in #433
  • Update credential storage docs and remove stale config.json references by betegon in #408

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Tests

  • Consolidate unit tests subsumed by property tests by BYK in #422
  • Remove redundant and low-value tests by BYK in #418

Other

  • (log/list) Convert non-follow paths to return CommandOutput by BYK in #410
  • Centralize slug normalization warning in parseOrgProjectArg by BYK in #436
  • Unify commands as generators with HumanRenderer factory, remove stdout plumbing by BYK in #416
  • Convert list command handlers to return data instead of writing stdout by BYK in #404
  • Split api-client.ts into focused domain modules by BYK in #405
  • Migrate non-streaming commands to CommandOutput with markdown rendering by BYK in #398
  • Convert Tier 2-3 commands to return-based output and consola by BYK in #394
  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

Codecov Results 📊

111 passed | Total: 111 | 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 1101 uncovered lines.
❌ Project coverage is 95.05%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
arg-parsing.ts 94.28% ⚠️ 19 Missing
view.ts 93.97% ⚠️ 12 Missing
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

@BYK BYK merged commit 0299d3d into main Mar 16, 2026
22 checks passed
@BYK BYK deleted the refactor/431-slug-normalization-helper branch March 16, 2026 19:26
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.

refactor: abstract slug normalization warning into shared helper

1 participant