Skip to content

fix(coderd/coderdtest): read the swagger doc once in TestSwaggerEnumsNotNarrowed - #32065

Merged
ThomasK33 merged 1 commit into
mainfrom
tk/fix-swagger-doc-race
Nov 11, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
tk/fix-swagger-doc-race

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Why

The test-go-race-pg job fails intermittently with WARNING: DATA RACE in swag.(*Spec).ReadDoc, on pull requests whose changes do not cause it. It failed CI runs 43102680650 and 43103681536 on two unrelated pull requests. A green rerun of the same commit passes, so it hides as a flake.

Cause

swag's Spec.ReadDoc writes shared state, so parallel tests that each call it race. #31829 addressed this by reading the spec once through swaggerDoc, a sync.OnceValue. #30122 then added TestSwaggerEnumsNotNarrowed with a direct apidoc.SwaggerInfo.ReadDoc() call, which races with the tests that still read the shared value.

What changed

TestSwaggerEnumsNotNarrowed calls swaggerDoc(), like the other tests. It was the only direct call outside the generated coderd/apidoc/docs.go.

Reproduction

  • On main (412d998), go test -race -count=20 -run 'TestSwagger|TestChatModelPathParametersFormatted' ./coderd/coderdtest/ fails with 2 data race reports. TestChatModelPathParametersFormatted, TestSwaggerParametersValid and TestSwaggerEnumsNotNarrowed fail.
  • With this change, the same command passes with no data race report.

Generated with xum • Model: anthropic:claude-sonnet-5-5 • Thinking: xhigh

…NotNarrowed

swag's `Spec.ReadDoc` writes shared state, so parallel tests that call it
race. #31829 routed the other tests through `swaggerDoc`, and #30122
added a direct call after it.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33
ThomasK33 temporarily deployed to main November 11, 2026 22:10 — with GitHub Actions Inactive
@ThomasK33
ThomasK33 temporarily deployed to main November 11, 2026 22:10 — with GitHub Actions Inactive
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T22:11:24.672565Z 41173eb Manual request
🔒 Security Review ✅ Completed 2026-11-11T22:13:07.270333Z 41173eb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 41173ebacc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 41173ebacc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 temporarily deployed to main November 11, 2026 22:31 — with GitHub Actions Inactive
@ThomasK33
ThomasK33 temporarily deployed to main November 11, 2026 22:47 — with GitHub Actions Inactive
@ThomasK33
ThomasK33 merged commit b61ec43 into main Nov 11, 2026
59 checks passed
@ThomasK33
ThomasK33 deleted the tk/fix-swagger-doc-race branch November 11, 2026 22:50
@ThomasK33
ThomasK33 temporarily deployed to main November 11, 2026 22:50 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 11, 2026

This branch was previously deployed

1 inactive deployment
main — 41173eba Deployed Nov 11, 2026 by ThomasK33 via cla #254542
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants