Skip to content

fix: parseIssueArg now checks slashes before dashes#177

Merged
BYK merged 2 commits intomainfrom
fix/arg-parsing-slash-precedence
Feb 5, 2026
Merged

fix: parseIssueArg now checks slashes before dashes#177
BYK merged 2 commits intomainfrom
fix/arg-parsing-slash-precedence

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 5, 2026

Summary

Fixes a parsing bug where org slugs containing dashes (e.g., my-org) were incorrectly parsed when used with explicit formats.

Supersedes PR #175 (property tests are included here with the fix)

The Bug

Input: my-org/123
Expected: { type: "explicit-org-numeric", org: "my-org", numericId: "123" }
Actual:   { type: "project-search", projectSlug: "my", suffix: "ORG/123" }

The parser was checking for dashes before slashes, causing my-org/123 to split on the dash first.

The Fix

Refactored parseIssueArg() to check slashes FIRST, then handle dashes within each part:

  1. Check if numeric → return numeric
  2. Check if contains / → parse as org/... format (slash takes precedence)
  3. Check if contains - → parse as project-suffix format
  4. Otherwise → return suffix-only

Changes

  • src/lib/arg-parsing.ts: Refactored to check slashes before dashes, extracted helper functions to reduce complexity
  • test/lib/arg-parsing.property.test.ts: Added 17 property tests that verify parsing invariants with randomly generated inputs (including org slugs with dashes)

Verification

bun test test/lib/arg-parsing.test.ts test/lib/arg-parsing.property.test.ts
# 45 pass, 0 fail, 1923 expect() calls

bun test  # Full suite
# 1016 pass, 0 fail
Cursor Bugbot reviewed your changes and found no issues for commit e481d86

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

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 ✨

  • (dsn) Add project root detection for automatic DSN discovery by BYK in #159
  • (issue) Replace --org/--project flags with /ID syntax by BYK in #161
  • (lib) Add anyTrue helper for parallel-with-early-exit pattern by BYK in #174
  • (telemetry) Add withTracing helper to reduce Sentry span boilerplate by BYK in #172

Bug Fixes 🐛

  • (types) Align schema types with Sentry API by betegon in #169
  • ParseIssueArg now checks slashes before dashes by BYK in #177
  • Address bugbot review comments on dsn-cache model-based tests by BYK in #176
  • Added nullable in substatus's zod validation by MathurAditya724 in #157

Internal Changes 🔧

  • (upgrade) Use centralized user-agent for GitHub API requests by BYK in #173

Other

  • test: add model-based tests for DSN and project cache by BYK in #171
  • test: add model-based and property-based testing with fast-check by BYK in #166

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 2175 uncovered lines.
✅ Project coverage is 70.81%. Comparing base (base) to head (head).

Files with missing lines (33)
File Patch % Lines
human.ts 31.80% ⚠️ 684 Missing
resolve-target.ts 10.74% ⚠️ 291 Missing
oauth.ts 25.10% ⚠️ 194 Missing
upgrade.ts 40.23% ⚠️ 153 Missing
api-client.ts 74.21% ⚠️ 138 Missing
resolver.ts 3.23% ⚠️ 120 Missing
errors.ts 5.94% ⚠️ 95 Missing
migration.ts 47.44% ⚠️ 82 Missing
version-check.ts 34.04% ⚠️ 62 Missing
telemetry.ts 77.43% ⚠️ 51 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
preload.ts 38.71% ⚠️ 38 Missing
seer.ts 79.87% ⚠️ 30 Missing
schema.ts 52.73% ⚠️ 26 Missing
utils.ts 87.43% ⚠️ 24 Missing
detector.ts 90.10% ⚠️ 20 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
auth.ts 94.78% ⚠️ 7 Missing
dsn-cache.ts 96.71% ⚠️ 7 Missing
project-root.ts 97.73% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
colors.ts 91.84% ⚠️ 4 Missing
env-file.ts 97.58% ⚠️ 3 Missing
sentry-urls.ts 88.00% ⚠️ 3 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
alias.ts 99.28% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    70.71%    70.81%     +0.1%
==========================================
  Files           55        55         —
  Lines         7445      7451        +6
  Branches         0         0         —
==========================================
+ Hits          5264      5276       +12
- Misses        2181      2175        -6
- Partials         0         0         —

Generated by Codecov Action

BREAKING: Changes parsing behavior for inputs like 'my-org/123'

Before: 'my-org/123' → project-search (project='my', suffix='org/123')
After:  'my-org/123' → explicit-org-numeric (org='my-org', numericId='123')

The fix ensures slashes take precedence over dashes, so org slugs with
dashes (e.g., 'my-org', 'acme-corp') work correctly with explicit formats.

Also includes property-based tests for parseIssueArg and parseOrgProjectArg
that verify parsing invariants with randomly generated inputs.
@BYK BYK force-pushed the fix/arg-parsing-slash-precedence branch from d7e54d3 to 0b9c54b Compare February 5, 2026 00:09
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

/cli-G now correctly parses as project-search with projectSlug='cli'
instead of suffix-only with suffix='CLI-G'.

Added test cases for /cli-G and /spotlight-electron-4Y patterns.
@BYK BYK merged commit 320a095 into main Feb 5, 2026
26 checks passed
@BYK BYK deleted the fix/arg-parsing-slash-precedence branch February 5, 2026 00:41
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