Skip to content

fix(wab): return 401 instead of 500 for logged-out personal API token calls - #173

Open
jameswillis99 wants to merge 1 commit into
plasmicapp:masterfrom
jameswillis99:fix/apitokens-anon-401
Open

jameswillis99 wants to merge 1 commit into
plasmicapp:masterfrom
jameswillis99:fix/apitokens-anon-401

Conversation

@jameswillis99

Copy link
Copy Markdown

Summary

A logged-out request to the personal API token routes (GET / PUT /api/v1/settings/apitokens) returns a 500 with NullOrUndefinedValueError. It now returns a 401.

 checkUserIdIsSelf(userId)
   if NormalUser: userId = actor.userId
   if SuperUser and no userId: throw
-  return ensure(userId)            // 500 NullOrUndefinedValueError
+  if no userId: throw UnauthorizedError   // 401
+  return userId

Evidence

DbMgr.user › rejects personal API token calls from anonymous users

anonymous listPersonalApiTokens() / createPersonalApiToken()
  expect rejects with UnauthorizedError
  • Before: fails, expected NullOrUndefinedValueError … to be an instance of UnauthorizedError
    After: passes. Full DbMgr.spec.ts: 56 passed, 2 skipped

Merge Danger

Door: two-way

Blast Radius: small

Only the error thrown when there is no user id changes. The same check guards the token routes, updateUser, updateAdminMode and claimPublicProject. Logged-in users are not affected.

…n routes

checkUserIdIsSelf asserted a user id with ensure, so a logged-out request to
the API token routes threw NullOrUndefinedValueError and returned a 500. It
now throws UnauthorizedError.
@vercel

vercel Bot commented Oct 15, 2026

Copy link
Copy Markdown

@jwillis24 is attempting to deploy a commit to the Plasmic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

Thank you for your submission, we really appreciate it! ❤️

Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. If you are contributing on behalf of a company, please contact us at help@plasmic.app to sign a Corporate Contributor License Agreement.

You can sign the individual CLA by posting a comment with the below text.


I have read, agree to, and hereby sign Plasmic's Individual Contributor License Agreement


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

This branch has not been deployed

No deployments
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.

2 participants