Skip to content

fix(cli): remove unnecessary PTY from TestServerCreateAdminUser/Validates#25444

Merged
johnstcn merged 5 commits into
mainfrom
cian/plat-224-flake-testservercreateadminuservalidates
May 19, 2026
Merged

fix(cli): remove unnecessary PTY from TestServerCreateAdminUser/Validates#25444
johnstcn merged 5 commits into
mainfrom
cian/plat-224-flake-testservercreateadminuservalidates

Conversation

@johnstcn
Copy link
Copy Markdown
Member

@johnstcn johnstcn commented May 18, 2026

Fixes https://linear.app/codercom/issue/PLAT-224

The Validates subtest only checks that Run() returns a validation error and never reads PTY output. We don't need it in this test, so removing.

🤖 Generated by Coder Agents

The Validates subtest only checks that Run() returns a validation error.
It never reads PTY output. The PTY copy goroutine would block on
io.Copy reading from the master fd, then race with pty.Close() during
t.Cleanup, causing a 10s timeout flake under the race detector.
@johnstcn johnstcn self-assigned this May 18, 2026
@johnstcn johnstcn marked this pull request as ready for review May 18, 2026 15:18
@johnstcn johnstcn requested review from Copilot and mafredri May 18, 2026 15:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes an unused PTY setup from the Validates subtest of TestServerCreateAdminUser to fix a flake under the race detector. The subtest only asserts on the validation error returned by Run() and never reads PTY output; the lingering copy goroutine could race with pty.Close() in t.Cleanup, causing a 10s timeout.

Changes:

  • Remove ptytest.New(t) and the assignments to root.Stdout/root.Stderr in the Validates subtest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was the root cause verified? I'm a bit skeptical that the reason is as written given there isn't a debugger analysis involved. The reason I raise this is because LLMs like creating plausible reasons, and if we include that in PR/commit messages, it may poison future LLM use.

While this change seems benign, aren't we just treating a symptom? I imagine we would still see this same class of flake elsewhere if we are to believe the reason/conclusion.

PS. If we don't want the output, we should use os.Discard for stdout and stderr to protect os.Stdout and os.Stderr from any unexpected or future output (also helps make it clear what we're testing).

@johnstcn
Copy link
Copy Markdown
Member Author

How was the root cause verified? I'm a bit skeptical that the reason is as written given there isn't a debugger analysis involved. The reason I raise this is because LLMs like creating plausible reasons, and if we include that in PR/commit messages, it may poison future LLM use.

I spent a few more brain tokens investigating and I think the actual correct fix is to pass a context into the outputExpecter as it creates its own testutil.Context. I'm going to merge this anyway.

@johnstcn johnstcn merged commit 8528946 into main May 19, 2026
26 checks passed
@johnstcn johnstcn deleted the cian/plat-224-flake-testservercreateadminuservalidates branch May 19, 2026 09:35
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
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.

3 participants