Skip to content

Reject Neon organization keys and say why - #78

Merged
raghubetina merged 2 commits into
mainfrom
neon-api-key-check
Oct 6, 2026
Merged

raghubetina merged 2 commits into
mainfrom
neon-api-key-check

Conversation

@raghubetina

Copy link
Copy Markdown
Contributor

Codespace attendees who pasted an organization or project Neon API key got SAVED, then auth.sh check neon failed with "sign-in expired or key rejected" and the skill sent them to an instructor.

Root cause, from neonctl 8.0.8's source: profile create --api-key - validates with GET /auth and accepts api_key_org keys (dist/commands/profile.js:274-292, dist/profile_keys.js:30-41), storing them in ~/.config/neon/credentials.json with an org_id. neonctl me calls GET /users/me, which answers 404 not allowed for organization API keys for those keys (dist/commands/user.js:20). Storage is consistent: me reads the same DEFAULT profile file that profile create DEFAULT writes.

  • check_neon asks neonctl profile list for the active credential (offline, no browser sign-in), names an organization or project key directly, and otherwise passes on neonctl me's first error sentence with long tokens redacted.
  • neon-key.sh save runs that check after storing the key and keeps the form when it fails.
  • The form, skill and README say to make a personal key (profile menu, Account settings, API keys), not the organization's API keys. The skill retries with a new personal key before getting the instructor.

Tested against a local stub of the Neon API with scratch homes: organization key, personal key, rejected key, unreachable API, hanging API, and an unreadable profiles file. Not tested with a real Neon key.

Attendees in browser Codespaces paste a Neon API key, and many made
an organization key from the organization's Settings > API keys.
neonctl 8.0.8's profile create accepts organization and project keys
(it validates with GET /auth, not /users/me) and saves them to
~/.config/neon/credentials.json as usual, but neonctl me then gets
404 "not allowed for organization API keys". The check reported
that as "sign-in expired or key rejected", and the skill sent the
attendee to an instructor.

The check now asks neonctl profile list for the credential it will
use, names an organization or project key without a network call,
and otherwise passes on neonctl me's own first error sentence with
tokens redacted. neon-key.sh save runs the check after storing the
key and keeps the form when it fails, so the attendee can paste a
personal key in its place. The form, skill and README now say to
make a personal key from Account settings, not the organization's
API keys, and the skill retries before escalating.
The pinned firstdraft/dockerfiles contract stubbed neonctl for
profile create only, so neon-key.sh save's new check failed there.
The repinned contract answers profile list and me, and covers both
an organization key and a personal key.
@raghubetina
raghubetina merged commit f02e134 into main Oct 6, 2026
1 check passed
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