fix(cli): return org slug, not display name, from org resolution#1232
fix(cli): return org slug, not display name, from org resolution#1232John-David Dalton (jdalton) merged 1 commit intomainfrom
Conversation
|
Cursor (@cursor) review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7f39ca3. Configure here.
|
Cursor (@cursor) review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7f39ca3. Configure here.
|
Cursor (@cursor) review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7f39ca3. Configure here.
|
Cursor (@cursor) review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7f39ca3. Configure here.
|
Cursor (@cursor) review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7f39ca3. Configure here.
|
Cursor (@cursor) review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7f39ca3. Configure here.
Bill Li (billxinli)
left a comment
There was a problem hiding this comment.
LGTM, just a question about the inline comment
1ac9ee1 to
754dd13
Compare
Orgs whose display name differs from the slug (e.g. a name with
spaces like "Example Org Ltd" vs slug "example-org-ltd") produced
broken API URLs like `/v0/orgs/Example%20Org%20Ltd/full-scans`
that 404'd. The CLI returned `.name` in two paths where it should
have returned `.slug`.
Fixed both call sites:
* commands/scan/suggest-org-slug.mts — interactive prompt now
uses the display name for the visible label/description but
sets the choice `value` to the slug. User sees the friendly
name, API calls route by slug.
* commands/ci/fetch-default-org-slug.mts — CI auto-resolve no
longer reads `.name` from the first org. Uses `.slug`. Also
simplified iteration: fetchOrganization already returns an
array via Object.values, so the previous
Object.keys(organizations)[0] indirection was meaningless.
Tests:
* Added regression coverage in both test files for the
name-differs-from-slug case using the dummy "Example Org Ltd"
fixture.
* Fixed the pre-existing "fetches from API" test in
fetch-default-org-slug.test.mts — it mocked organizations as
a dict but the real shape is an array, and asserted the buggy
display-name return value. Now asserts slug.
* Renamed "returns error when organization has no name" to
"returns error when organization has no slug" with a matching
mock payload — the new defensive check guards against missing
slug, not missing name.
754dd13 to
2643c2c
Compare
The bug
Orgs whose display name differs from the slug (most obviously, names with spaces like "Example Org Ltd" vs slug
example-org-ltd) produced broken API URLs when the CLI picked the org automatically or prompted the user to pick one:Two call sites were returning
.namewhen they should have been returning.slug.Fix
commands/scan/suggest-org-slug.mts— interactive prompt. Visible label and description still use the friendlier display name; the choicevaluenow carries the slug. User sees "Example Org Ltd", we route with "example-org-ltd".commands/ci/fetch-default-org-slug.mts— CI auto-resolve. No longer reads.namefrom the first org; uses.slug. Also dropped theObject.keys(organizations)[0]indirection sincefetchOrganizationalready returns an array viaObject.values.Tests
example-org-ltdfixture.fetches from APItest infetch-default-org-slug.test.mts— it mockedorganizationsas a dict but the real shape is an array, and asserted the buggy display-name return value. Now asserts slug.returns error when organization has no name→returns error when organization has no slugwith a matching mock payload. The new defensive check guards against a missing slug, not a missing name.Test plan
pnpm run typecleanpnpm --filter @socketsecurity/cli run test:unit— 339 files / 5106 tests passpnpm run build:clisucceeds