Skip to content

fix: pass expected @scope:team format to backend#90

Merged
danielroe merged 6 commits intomainfrom
fix/cli-scope-team-validation
Jan 26, 2026
Merged

fix: pass expected @scope:team format to backend#90
danielroe merged 6 commits intomainfrom
fix/cli-scope-team-validation

Conversation

@serhalp
Copy link
Copy Markdown
Member

@serhalp serhalp commented Jan 26, 2026

Bug

  1. pnpm dev
  2. pnpm npmx-connector
  3. navigate to http://localhost:3001/org/<some-org> (or directly to destination http://localhost:3001/@org), where <some-org> is an org your logged in user is a part of
  4. page hangs for ~30s, eventually loads and the npmx-connector prints an error
Screenshot 2026-01-25 at 19 07 17

This is really two separate fixes:

fix(cli): fail gracefully on invalid scope:team format

The /team/:scopeTeam/users endpoint was letting validation errors from validateScopeTeam bubble up as an unhandled 500 response with an unhandled rejection logged to the console. Now it catches and returns a proper 400 with a helpful message, and logs the full error.

fix(app): add @ prefix when constructing scope:team for npm operations

npm team/access operations require @scope:team format but the frontend was sending scope:team
without the @ prefix.

This was obscured by the fact that the admin operations aren't quite functional yet for most orgs as OTP isn't supported, and by the fact that listTeamUsers only fails with this incorrect format when it goes through the CLI, which is only the case for the authenticated user's own orgs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
npmx.dev Ready Ready Preview, Comment Jan 26, 2026 2:47pm

Request Review

The `/team/:scopeTeam/users` endpoint was letting validation errors from `validateScopeTeam` bubble up
as an unhandled 500 response with an unhandled rejection logged to the console. Now it catches and
returns a proper 400 with a helpful message, and logs the full error.
npm team/access operations require `@scope:team` format but the frontend was sending `scope:team`
without the `@` prefix.

This was obscured by the fact that the admin operations aren't quite functional yet for most orgs as
OTP isn't supported, and by the fact that `listTeamUsers` only fails with this incorrect format when
it goes through the CLI, which is only the case for the authenticated user's own orgs.
@serhalp serhalp force-pushed the fix/cli-scope-team-validation branch from 89d989b to de872d3 Compare January 26, 2026 01:19
@serhalp serhalp marked this pull request as ready for review January 26, 2026 01:31
Comment thread cli/src/logger.ts
/**
* Log a debug message with `obug` (minimal fork of `debug`)
*/
export const logDebug = createDebug('npmx-connector')
Copy link
Copy Markdown
Member Author

@serhalp serhalp Jan 26, 2026

Choose a reason for hiding this comment

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

I might be missing something, but debugging was difficult without stack traces and support for non-string objects in general. Given that clack doesn't have affordances for this, debug/obug was the least intrusive approach I could think of.

Comment thread cli/src/server.ts
Comment on lines +455 to +460
logError('scope:team validation failed')
logDebug(err, { scopeTeamRaw, scopeTeam })
throw new HTTPError({
statusCode: 400,
message: `Invalid scope:team format: ${scopeTeam}. Expected @scope:team`,
})
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This may look a little funny at a glance, but the logError is the backend-user-facing pretty clack error output, the logDebug is for a developer troubleshooting, and the throw is for the response back to the browser for this invalid request.

Copy link
Copy Markdown

@mxdvl mxdvl Jan 26, 2026

Choose a reason for hiding this comment

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

Would it help putting quotes around the invalid input for clarity?

@serhalp serhalp requested a review from danielroe January 26, 2026 01:41
Comment thread app/utils/npm.ts Outdated
Copy link
Copy Markdown
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

thank you ❤️

@danielroe danielroe merged commit 3a1f876 into main Jan 26, 2026
8 checks passed
@danielroe danielroe deleted the fix/cli-scope-team-validation branch January 26, 2026 14:49
vinnymac pushed a commit to vinnymac/npmx.dev that referenced this pull request Jan 28, 2026
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.

3 participants