Repository navigation
test(api): enforce race coverage for token cache - #263
Conversation
a50beab to
e0a2cdc
Compare
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — this run covered the full PR (1 commit): the new client race CI step, the strengthened token-cache race tests, and the two request-building tests converted to recording transports.
- CI race gate: new
test-job step runsgo test -race -count=1 -timeout 5m ./internal/client/...before the coverage pass, scoped client-only so #259 stays separate. - Hermetic request-building tests:
TestGetAuthorizedWithToken_NilTokenandTestDoRequestWithTokenRequestBuildingswap real-networkNew(nil, nil)clients for recording transports, now asserting method, URL, and the exactAuthorizationheader (plus that invalid requests never reach the transport). - Strengthened race regressions: the fallback test alternates two different-length tokens and asserts every recorded
Authorizationheader is one of the two complete bearers (count 1:1 with requests); the login test seeds a fallback token, checks everyGetCourseserror, and asserts the login token lands in both the client cache andcfg.Token.
Verified in both directions: the exact new CI command passes on this head (ok internal/client 4.551s), and a client_auth.go overlay with all eight tokenMu calls stripped makes both race tests fail under -race — the gate genuinely catches a missing lock, which is the whole point of #255.
glm-5.3 | 𝕏
| iterations = 200 | ||
| ) | ||
| tokens := [...]string{firstToken, secondToken} | ||
| headers := make(chan string, iterations) |
There was a problem hiding this comment.
[SUGGESTION]: Exact-capacity buffered channel turns over-calls into a CI hang instead of an assertion failure
The buffer holds exactly the expected request count and the transport send blocks once it is full. assertTokenRaceHeaders's count check exists to catch a wrong number of requests, but if the client ever issues more than iterations requests (e.g. a future retry or redirect is added), the blocked send stalls GetCourses, wait.Wait() deadlocks, and this step burns the full 5-minute CI timeout instead of failing fast on the count mismatch. The same pattern exists in TestClientLoginAndFallbackRequestsShareTokenSafely (channel at line 86, handler send at line 95). Consider a non-blocking send that records drops, or an oversized buffer, so over-calls actually reach the count assertion.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| t.Fatalf("cached token = %q, want %q", got, token) | ||
| close(headers) | ||
| assertTokenRaceHeaders(t, headers, iterations, firstToken, secondToken) | ||
| if got := apiClient.tokenValue(); got != secondToken { |
There was a problem hiding this comment.
[SUGGESTION]: Final-token assertion is silently coupled to the parity of iterations
This passes deterministically today only because iterations is even: the writer's last write is tokens[199%2] == secondToken. If iterations is ever changed to an odd value (e.g. while stress-tuning this constant), the last written token becomes firstToken and this assertion fails with a "want last written token" message that no longer matches the writer. Derive the expectation from the same expression the writer uses, e.g. wantLast := tokens[(iterations-1)%len(tokens)], and use it in both this comparison and the fatal message.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Reviewed by glm-5.3-flash · Input: 68.1K · Output: 17.5K · Cached: 371.8K Review guidance: REVIEW.md from base branch |

Opened by my assistant.
Summary
Fixes #255.
go test -race -count=1 -timeout 5m ./internal/client/...to CIThe race step is deliberately client-only; unrelated process timing issue #259 remains separate. No production code changes.
Validation
-buildvcs=falsepassFull
go test ./...was attempted. All packages except the nine pre-existing player tests pass; this sandbox prohibits AF_UNIX sockets. Worktree builds require-buildvcs=falsedue to the environment's VCS lookup. Hosted CI and Security passed on the final head: https://github.com/rabesss/impartus-cli/actions/runs/37479525609. The latest title check also passes.