Skip to content

fix(coderd/coderdtest): render the Swagger spec once in parallel tests - #31829

Merged
ethanndickson merged 1 commit into
mainfrom
fix-swagger-readdoc-race
Nov 9, 2026
Merged

ethanndickson merged 1 commit into
mainfrom
fix-swagger-readdoc-race

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Why

test-go-race-pg fails on PRs that touch no Go product code, for example two runs on #31782. Since #30124, two parallel tests in coderd/coderdtest call swag's Spec.ReadDoc, which writes shared state, so the race detector fails the whole package (WARNING: DATA RACE in swag.(*Spec).ReadDoc, swagger_test.go:41 and :77).

What changed

swagger_test.go renders the spec once through sync.OnceValue, and both tests read that string.

Verification

  • On main, go test -race -count=20 -run 'TestSwaggerParametersValid|TestChatModelPathParametersFormatted' ./coderd/coderdtest/ reported 4 data races and failed.
  • With this change, the same command passed with 0 races.
  • golangci-lint reports 0 issues for ./coderd/coderdtest/ with both the main and the new-code configs.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

swag's Spec.ReadDoc writes shared state. TestSwaggerParametersValid and
TestChatModelPathParametersFormatted call it in parallel, and the race
detector fails coderd/coderdtest in test-go-race-pg. Render the spec once
with sync.OnceValue.
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T08:51:11.159059Z 523a316 Manual request
🔒 Security Review ✅ Completed 2026-11-06T08:51:46.476741Z 523a316 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. Breezy!

Reviewed commit: 523a316e94

ℹ️ 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: 523a316e94

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.

@ethanndickson
ethanndickson merged commit 70f62ae into main Nov 9, 2026
51 checks passed
@ethanndickson
ethanndickson deleted the fix-swagger-readdoc-race branch November 9, 2026 06:37
@ethanndickson
ethanndickson temporarily deployed to main November 9, 2026 06:37 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 9, 2026

This branch was previously deployed

1 inactive deployment
main — 523a316e Deployed Nov 9, 2026 by ethanndickson via cla #252291
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