Repository navigation
fix(api): skip writing back an unchanged preferred namespace on login - #7385
Conversation
|
Claude finished @luizhf42's task in 1m 15s —— View job Code Review CompleteI reviewed 2 files for Standards (repo rules, Go conventions, tests, code smells) and Correctness (security and runtime defects). I found no new issues, and the code looks good as it is. The Spec axis did not run because the PR references no issue. I did all of the review myself rather than splitting it across the four sub-agents the procedure calls for, because the diff is 22 lines. What I checked:
|
45f25e9 to
9818dd4
Compare
9818dd4 to
737e129
Compare
|
/review |
|
Claude finished @gustavosbarreto's task in 1m 10s —— View job Code Review CompleteReviewed 2 files for Standards (repo rules, Go conventions, tests, code smells) and Correctness (security and runtime defects). I found no new issues, and the code looks good as it is. The Spec axis did not run because the PR and its commit reference no issue. |
737e129 to
d5c186e
Compare
d5c186e to
ed9c26b
Compare
`AuthLocalUser` reads the user's preferred namespace and then writes it back, changed or not. When the namespace is deleted between the read and the write, `ON DELETE SET NULL` clears the column, and the write puts the deleted namespace's ID back. The foreign key rejects it and login answers 500. The cloud e2e job hit this when a test polled login right after deleting a namespace: violates foreign key constraint "users_preferred_namespace_id_fkey" Login now writes the preferred namespace only when it differs from the one it read, as `CreateUserToken` already does. The service tests that expected a write of an unchanged value no longer expect one, so a write back of the same namespace fails them.
ed9c26b to
e5dff2b
Compare
Summary
Stacked on #7378 so the cloud e2e job runs with the billing test already fixed. The two changes don't depend on each other.
AuthLocalUserreads the user's preferred namespace and then writes it back, changed or not. If the namespace is deleted between the read and the write,ON DELETE SET NULLclears the column, the write puts the deleted ID back, and the foreign key turns login into a 500.CreateUserTokenalready does this check.Evidence
billing.spec.ts:377"a namespace with an active subscription is deleted only once it is canceled". The test polls login right after deleting the namespace, and the server logged:POST /api/login 500 ... violates foreign key constraint "users_preferred_namespace_id_fkey"TestService_AuthLocalUsercases no longer expect a write of the unchanged value, so a write back fails them. Against the oldauth.go, "succeeds to authenticate without a namespace" fails. With the fix, all ofserver/api/servicespasses.The race is still there when the value changes: a user with no preferred namespace whose login picks a namespace being deleted at that moment. That window is much narrower, and nothing has hit it.
Merge Danger
Door: two-way
Blast Radius: login
Login skips a write that stored the value already in the column. The token and its claims are unchanged.