Skip to content

flake: TestAutoPromote_InsertFailureSkipsStatusUpdate #1506

@flake-investigator

Description

@flake-investigator

CI Run: https://github.com/coder/coder/actions/runs/25106322983
Failed Job: test-go-pg-17 (https://github.com/coder/coder/actions/runs/25106322983/job/73570970531)
Commit: 5ceca94e0c979480d6a5892b48b3f2b7bbb67926 (author: Mathias Fredriksson)

Failure:

=== FAIL: coderd/x/chatd TestAutoPromote_InsertFailureSkipsStatusUpdate (0.00s)
    t.go:111: 2026-04-29 11:53:37.717 [info]  processing chat request  chat_id=dd3b9546-aa3e-4448-9a7d-8440df6223c8
    t.go:114: 2026-04-29 11:53:37.717 [erro]  failed to process chat  chat_id=dd3b9546-aa3e-4448-9a7d-8440df6223c8 ...
        error= resolve model config:
               github.com/coder/coder/v2/coderd/x/chatd.(*Server).resolveChatModel.func1
                 /home/runner/work/coder/coder/coderd/x/chatd/chatd.go:7226
             - get chat model config 0530443c-8602-4169-a77b-5b1783d68a38:
               github.com/coder/coder/v2/coderd/x/chatd.(*Server).resolveModelConfig
                 /home/runner/work/coder/coder/coderd/x/chatd/chatd.go:7354
             - no model:
               github.com/coder/coder/v2/coderd/x/chatd.TestAutoPromote_InsertFailureSkipsStatusUpdate.func1
                 /home/runner/work/coder/coder/coderd/x/chatd/chatd_internal_test.go:4855
    chatd.go:5157: Unexpected call to *dbmock.MockStore.UpdateChatStatus([...])
        expected call at /home/runner/work/coder/coder/coderd/x/chatd/chatd_internal_test.go:4879 has already been called the max number of times
    controller.go:97: missing call(s) to *dbmock.MockStore.InsertChatMessages(...)
    controller.go:97: missing call(s) to *dbmock.MockStore.GetChatModelConfigByID(...)
    controller.go:97: missing call(s) to *dbmock.MockStore.GetChatQueuedMessages(...)
    controller.go:97: missing call(s) to *dbmock.MockStore.PopNextQueuedMessage(...)
    controller.go:97: aborting test due to missing call(s)

Error analysis:

  • Single test failure in coderd/x/chatd/chatd_internal_test.go.
  • The mocked model-resolution path returns no model after the interrupt is published. When this path wins the race, runChat exits with a resolve-model error (not ErrInterrupted), so finishActiveChat still calls UpdateChatStatus. This violates the test’s expectation that the auto-promote transaction runs and that UpdateChatStatus is never called.
  • Missing mock calls indicate the auto-promotion path never executed, consistent with the status being set to error instead of waiting.

Root cause classification: Flaky test (timing/ordering between interrupt handling and blocked model resolution in mocked path).

Assignment analysis:

  • git blame -L 4825,4935 coderd/x/chatd/chatd_internal_test.go
    • Points to commit 782b7166 ("fix: preserve stream state on interrupt, fix auto-promote error handling") by Mathias Fredriksson, which introduced this test.
  • git log --oneline -10 --follow coderd/x/chatd/chatd_internal_test.go shows the same recent change.

Assignee: @mafredri

Race/Panic/OOM evidence:

  • No WARNING: DATA RACE, panic, or OOM indicators found in logs.

Related issues search (coder/internal):

Reproduction (if needed):

go test ./coderd/x/chatd -run TestAutoPromote_InsertFailureSkipsStatusUpdate -count=1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions