Skip to content

fix(token): name the organization a token is pinned to - #20

Open
roncodes wants to merge 1 commit into
mainfrom
fix/token-organization-message
Open

roncodes wants to merge 1 commit into
mainfrom
fix/token-organization-message

Conversation

@roncodes

@roncodes roncodes commented Dec 4, 2026

Copy link
Copy Markdown
Member

Problem

flb token create -o <org-slug> ends its success line with pinned to undefined:

✓ Created token ci (tok_…), scopes install, expires 2027-12-04, pinned to undefined.

The Registry Service returns a token's organization as the organization's id ("org_…", see TokenResource), and the CLI read .slug from it as if it were an object. The token itself is pinned correctly; only the output is wrong.

Changes

  • flb token create: the message names the organization passed with -o/--organization, and otherwise what the response carries: the slug of an object, or the id string. Nothing is said about pinning when the response has no organization.
  • flb token list: the same assumption left the ORG column empty for every pinned token. It now shows the slug. When a token carries only the id, the slug is looked up from GET /v1/account (one extra request, only when a listed token is pinned by id); if that lookup fails, the id is shown.
  • flb token create --save: the stored default organization came from details.organization?.slug, so it silently kept the previous default. It now takes the slug passed with -o (an id passed with -o is not stored as a slug).
  • TokenDetails.organization is typed as string | { id?, slug?, name? } | null.

--json output is unchanged: it passes the service's response through. No API change.

Tests

test/unit/auth.test.ts covers the create message, --save and the list column with both response shapes (id string, object with a slug), plus the unpinned case and the failed account lookup. The three new tests fail on main and pass here. npm run typecheck, npm run build and npm test (136 tests) pass locally.

Release

There is no open release/v* branch (v2.0.1 merged and its branch is gone), so this targets main. Merging it does not tag or publish: release.yml only tags when a release/v* branch merges. It ships with the next release branch, which needs the version bump in package.json / package-lock.json and a RELEASE.md entry for this fix.

flb token create -o <org> ended its success line with "pinned to undefined". The
Registry Service returns a token's organization as its id (org_…), and the CLI read
.slug from it as if it were an object. The token itself was pinned correctly.

The message now names the organization passed with -o, and otherwise whatever the
response carries: a slug from an object, or the id. The same assumption left the ORG
column of flb token list empty for pinned tokens; it now shows the slug, looked up
from the account when a token carries only the id, and the id when that lookup fails.
token create --save also kept the previous default organization instead of the one
the new token is pinned to.

--json output is unchanged: it passes the service's response through.
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