Skip to content

fix(issue): handle cross-org project slug collisions in alias generation#62

Merged
BYK merged 5 commits intomainfrom
fix/issue-48-alias-collisions
Jan 24, 2026
Merged

fix(issue): handle cross-org project slug collisions in alias generation#62
BYK merged 5 commits intomainfrom
fix/issue-48-alias-collisions

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Jan 24, 2026

Summary

Fixes #48 - Project alias collisions when multiple orgs have the same project slug.

Problem

The buildProjectAliasMap function only considered project slugs when computing aliases, ignoring the organization. This caused collisions when two projects from different orgs had the same slug (e.g., org1:dashboard and org2:dashboard both got alias d), making one project's issues inaccessible via alias shortcuts.

Solution

  • Added buildOrgAwareAliases() function that detects cross-org slug collisions
  • For colliding slugs: generates {orgPrefix}-{projectPrefix} format (e.g., o1-d, o2-d)
  • For unique slugs: preserves existing short alias behavior (e.g., f, b)
  • Stores both hyphenated (o1-d) and compact (o1d) formats for ease of use

Behavior

Scenario Before After
Single org: acme:frontend, acme:backend f, b f, b (unchanged)
Multi-org collision: org1:dashboard, org2:dashboard Both d (bug) o1-d, o2-d

Testing

Added 10 test cases covering collision detection, org prefix generation, and edge cases.

When multiple organizations have projects with the same slug (e.g.,
org1:dashboard and org2:dashboard), the alias generation now produces
unique aliases by prefixing with an org abbreviation (e.g., o1-d, o2-d).

- Add buildOrgAwareAliases() to detect and handle slug collisions
- Store both hyphenated (o1-d) and compact (o1d) formats for ease of use
- Preserve existing short alias behavior for non-colliding projects

Fixes #48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 24, 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 ✨

Issue

  • Add workspace-scoped alias cache by BYK in #52
  • Add short ID aliases for multi-project support by BYK in #31

Other

  • (api) Align with gh api and curl conventions by BYK in #60
  • (auth) Add press 'c' to copy URL during login flow by betegon in #58
  • (commands) Rename get commands to view and add -w browser flag by BYK in #53

Bug Fixes 🐛

Issue

  • Handle cross-org project slug collisions in alias generation by BYK in #62
  • Use org-scoped endpoint for latest event + enhanced display by betegon in #40

Other

  • (api) Use query params for --field with GET requests by BYK in #59

Documentation 📚

  • Update command references from 'get' to 'view' and document -w flag by BYK in #54

Internal Changes 🔧

  • (release) Fix changelog-preview permissions by BYK in #41
  • Rename config folder from .sentry-cli-next to .sentry by BYK in #50

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 24, 2026

Codecov Results 📊

✅ Patch coverage is 99.24%. Project has 1424 uncovered lines.
✅ Project coverage is 63.25%. Comparing base (base) to head (head).

Files with missing lines (18)
File Patch % Lines
human.ts 18.35% ⚠️ 672 Missing
oauth.ts 21.71% ⚠️ 202 Missing
resolver.ts 3.23% ⚠️ 120 Missing
errors.ts 5.94% ⚠️ 95 Missing
api-client.ts 64.11% ⚠️ 89 Missing
fixture.ts 28.74% ⚠️ 62 Missing
errors.ts 51.61% ⚠️ 60 Missing
api.ts 89.78% ⚠️ 47 Missing
preload.ts 39.02% ⚠️ 25 Missing
detector.ts 87.79% ⚠️ 16 Missing
cache.ts 76.27% ⚠️ 14 Missing
config.ts 97.11% ⚠️ 7 Missing
index.ts 95.06% ⚠️ 4 Missing
colors.ts 91.84% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
alias.ts 98.56% ⚠️ 2 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    60.64%    63.25%    +2.61%
==========================================
  Files           33        33         —
  Lines         3775      3875      +100
  Branches         0         0         —
==========================================
+ Hits          2289      2451      +162
- Misses        1486      1424       -62
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review January 24, 2026 16:33
- Use findShortestUniquePrefixes for colliding project slugs to handle
  cases like 'api' and 'app' both colliding across orgs (prevents
  identical aliases like 'o1-a' for both)
- Remove compact alias storage (e.g., 'o1d' for 'o1-d') to avoid
  potential overwrites and edge cases with hyphenated org names
- Add test for same-letter colliding project slugs
…ollision

Change the separator in org-prefixed aliases from hyphen to colon
(e.g., 'o1:d' instead of 'o1-d'). This prevents potential collisions
between unique project aliases (which can contain hyphens) and
colliding project aliases.

Since Sentry slugs cannot contain colons, the two alias namespaces
are now completely disjoint.
Add a dedicated ALIAS column in multi-project mode that shows the
typeable shorthand (e.g., 'o1:d-a3') for each issue. This replaces
the previous approach of trying to underline parts of the short ID.

Changes:
- Add COL_ALIAS constant (15 chars) for the new column
- Update formatIssueListHeader to conditionally show ALIAS column
- Update formatIssueRow to include alias shorthand in multi-project mode
- Simplify formatShortId since alias is now in its own column
- Add tests for ALIAS column formatting

Layout in multi-project mode:
  LEVEL  ALIAS          SHORT ID              COUNT  SEEN     TITLE
  ERROR  o1:d-a3        DASHBOARD-A3            42  2h ago   Something broke

Layout in single-project mode (unchanged):
  LEVEL  SHORT ID              COUNT  SEEN     TITLE
  ERROR  DASHBOARD-A3            42  2h ago   Something broke
Copy link
Copy Markdown
Contributor

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

The strippedPrefix field was no longer used after simplifying formatShortId()
to show alias in a dedicated ALIAS column. This removes:
- strippedPrefix from FormatShortIdOptions type
- strippedPrefix from OrgAwareAliasResult type
- References in list.ts and related tests

The prefix stripping logic is preserved internally in alias.ts for generating
short aliases, but is no longer exposed in the return type.
@BYK BYK merged commit 8d4c930 into main Jan 24, 2026
15 checks passed
@BYK BYK deleted the fix/issue-48-alias-collisions branch January 24, 2026 23:25
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.

Bug: Project alias collisions when multiple orgs have same project slug

1 participant