CI failure details
Failure and race evidence
The complete 6,839-line race-job log was reviewed. The first concrete race is in TestActiveServer_BasicAssistantGenerationAndPromptPreparation; the many subsequent coderd/x/chatd test failures are package-level fallout after the race detector fired.
WARNING: DATA RACE
Read at 0x00c016311378 by goroutine 49623:
github.com/coder/coder/v2/coderd/x/chatd_test.TestActiveServer_BasicAssistantGenerationAndPromptPreparation.func1()
/home/runner/work/coder/coder/coderd/x/chatd/chatd_test.go:6299 +0x33
github.com/coder/coder/v2/coderd/x/chatd/chattest.(*anthropicServer).handleMessages()
/home/runner/work/coder/coder/coderd/x/chatd/chattest/anthropic.go:167 +0x321
Previous write at 0x00c016311378 by goroutine 494:
github.com/coder/coder/v2/coderd/x/chatd_test.TestActiveServer_BasicAssistantGenerationAndPromptPreparation()
/home/runner/work/coder/coder/coderd/x/chatd/chatd_test.go:6346 +0x1b24
The detector also reports races inside the recorder object itself:
WARNING: DATA RACE
Write at 0x00c01d3726e0 by goroutine 49623:
sync/atomic.CompareAndSwapInt32()
github.com/coder/coder/v2/coderd/x/chatd_test.TestActiveServer_BasicAssistantGenerationAndPromptPreparation.func1()
/home/runner/work/coder/coder/coderd/x/chatd/chatd_test.go:6299 +0x45
Previous write at 0x00c01d3726e0 by goroutine 494:
github.com/coder/coder/v2/coderd/x/chatd_test.newAnthropicRequestRecorder()
/home/runner/work/coder/coder/coderd/x/chatd/chatd_helpers_test.go:32 +0x1ae4
github.com/coder/coder/v2/coderd/x/chatd_test.TestActiveServer_BasicAssistantGenerationAndPromptPreparation()
/home/runner/work/coder/coder/coderd/x/chatd/chatd_test.go:6346 +0x1b16
A third trace shows anthropicRequestRecorder.record() reading the recorder while the test overwrites it.
No panic, OOM, resource-exhaustion, or abnormal process-termination evidence was present.
Error analysis / root cause
Classification: Data race.
The Anthropic test server callback closes over the local requests variable:
requests := newAnthropicRequestRecorder()
anthropicURL := chattest.NewAnthropic(t, func(req *chattest.AnthropicRequest) chattest.AnthropicResponse {
requests.record(req)
// ...
})
Later, the same test reassigns that captured variable before starting another server scenario:
requests = newAnthropicRequestRecorder()
An HTTP handler goroutine from the first scenario can still execute the callback while the test goroutine replaces requests. The recorder's mutex protects its slice, but it cannot protect reassignment of the captured pointer. This is a test-code concurrency bug, not infrastructure. A likely fix is to use separate immutable recorder variables/callbacks per scenario, or explicitly stop and await the first server before replacing shared state.
Assignment analysis
Intended line-level blame command:
git blame -L 6289,6368 coderd/x/chatd/chatd_test.go
Line-level blame is unavailable in this environment, so file history and parent-revision comparison were used:
git log --oneline -10 --follow coderd/x/chatd/chatd_test.go
TestActiveServer_BasicAssistantGenerationAndPromptPreparation is absent from parent 4a07f61c501aa0cadcee4d7aa4f126c74c7872f4.
- It appears in
4debd23cbb2e8c946388d753ba51b58f3cd08eaa (fix: chatd refactor (#26270)) by Hugo Dutka, including the captured recorder and later reassignment.
- Later commits changed surrounding chat behavior but retained this race-prone structure.
Assigning to @hugodutka as the author of the failing test function. This assignment is based on test ownership, not the failing CI commit author.
Duplicate search
No direct duplicate was found after searching coder/internal for:
TestActiveServer_BasicAssistantGenerationAndPromptPreparation
BasicAssistantGeneration + race
anthropicRequestRecorder / newAnthropicRequestRecorder
chatd_test.go:6299
chatd_helpers_test.go + data race
WARNING: DATA RACE + chatd
- recently closed chatd race issues in the last 30 days
Related but different root causes: #1599 and #1450.
Reproduction
go test ./coderd/x/chatd -race -run TestActiveServer_BasicAssistantGenerationAndPromptPreparation -count=100
CI failure details
test-go-race-pg— https://github.com/coder/coder/actions/runs/30159875651/job/896833747466159eb4fc533a90e9acbb0b40b963679aad9e396by Michael Suchacz — coder/coder@6159eb4Failure and race evidence
The complete 6,839-line race-job log was reviewed. The first concrete race is in
TestActiveServer_BasicAssistantGenerationAndPromptPreparation; the many subsequentcoderd/x/chatdtest failures are package-level fallout after the race detector fired.The detector also reports races inside the recorder object itself:
A third trace shows
anthropicRequestRecorder.record()reading the recorder while the test overwrites it.No panic, OOM, resource-exhaustion, or abnormal process-termination evidence was present.
Error analysis / root cause
Classification: Data race.
The Anthropic test server callback closes over the local
requestsvariable:Later, the same test reassigns that captured variable before starting another server scenario:
An HTTP handler goroutine from the first scenario can still execute the callback while the test goroutine replaces
requests. The recorder's mutex protects its slice, but it cannot protect reassignment of the captured pointer. This is a test-code concurrency bug, not infrastructure. A likely fix is to use separate immutable recorder variables/callbacks per scenario, or explicitly stop and await the first server before replacing shared state.Assignment analysis
Intended line-level blame command:
Line-level blame is unavailable in this environment, so file history and parent-revision comparison were used:
TestActiveServer_BasicAssistantGenerationAndPromptPreparationis absent from parent4a07f61c501aa0cadcee4d7aa4f126c74c7872f4.4debd23cbb2e8c946388d753ba51b58f3cd08eaa(fix: chatd refactor (#26270)) by Hugo Dutka, including the captured recorder and later reassignment.Assigning to @hugodutka as the author of the failing test function. This assignment is based on test ownership, not the failing CI commit author.
Duplicate search
No direct duplicate was found after searching
coder/internalfor:TestActiveServer_BasicAssistantGenerationAndPromptPreparationBasicAssistantGeneration+raceanthropicRequestRecorder/newAnthropicRequestRecorderchatd_test.go:6299chatd_helpers_test.go+data raceWARNING: DATA RACE+chatdRelated but different root causes: #1599 and #1450.
Reproduction
go test ./coderd/x/chatd -race -run TestActiveServer_BasicAssistantGenerationAndPromptPreparation -count=100