Fix flaky SessionFs workspace metadata E2E test#1599
Merged
Conversation
The Should_Write_Workspace_Metadata_Via_SessionFs test waited only for workspace.yaml to exist before reading it, but the runtime creates the file (truncating to 0 bytes) before the content write completes. This let the test read an empty file and fail the session-id assertion. Wait for the expected content (not just existence) before asserting in both the .NET workspace.yaml and plan.md tests, and drop the now-redundant trailing asserts. Apply the same content-aware wait to the Python suite via its existing wait_for_content helper. Go already waits for content and Node uses an in-memory provider with atomic writes, so neither was affected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces intermittent CI failures in the SessionFs workspace-metadata E2E tests by switching from “wait for file existence” to “wait until file contains expected content”, avoiding a race where the runtime truncates/creates the file before content is fully written.
Changes:
- Python: replace
wait_for_path + read_text + assertwith a singlewait_for_content(...)forworkspace.yamlandplan.md. - .NET: update
WaitForConditionAsyncpredicates to require both file existence and expected content before proceeding (removing the follow-upAssert.Containsthat could still race on empty reads).
Show a summary per file
| File | Description |
|---|---|
| python/e2e/test_session_fs_e2e.py | Uses wait_for_content for workspace.yaml and plan.md to avoid empty/partial reads immediately after file creation/truncation. |
| dotnet/test/E2E/SessionFsE2ETests.cs | Waits for workspace.yaml / plan.md to contain expected substrings (session id / plan text) rather than only waiting for the files to exist. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
Contributor
Cross-SDK Consistency Review ✅I reviewed this PR against all six SDK implementations. The changes are consistent and the PR description's analysis is accurate.
No further changes needed for cross-SDK consistency.
|
edburns
pushed a commit
that referenced
this pull request
Jun 8, 2026
The Should_Write_Workspace_Metadata_Via_SessionFs test waited only for workspace.yaml to exist before reading it, but the runtime creates the file (truncating to 0 bytes) before the content write completes. This let the test read an empty file and fail the session-id assertion. Wait for the expected content (not just existence) before asserting in both the .NET workspace.yaml and plan.md tests, and drop the now-redundant trailing asserts. Apply the same content-aware wait to the Python suite via its existing wait_for_content helper. Go already waits for content and Node uses an in-memory provider with atomic writes, so neither was affected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
Should_Write_Workspace_Metadata_Via_SessionFsC# E2E test fails intermittently in CI (e.g. this run) with:Root cause
The test waited only for
workspace.yamlto exist before reading it. The runtime writes that file via the SessionFs provider using a truncate-then-write (File.WriteAllTextAsync), soFile.Existsreturns true the moment the file is created/truncated to 0 bytes, before the content is flushed. The test could read the empty file in that window and fail the assertion. The same race existed in the siblingplan.mdtest.Fix
Wait for the expected content (not just existence) before asserting. Since the content-aware wait already throws on timeout, the trailing
Assert.Containscalls became redundant and were removed, leaving the wait as the assertion (matching the existingindex.mdwait-only style in this file).I checked the equivalent test in every other language suite:
workspace.yamlandplan.mdtests to the already-present (but unused)wait_for_contenthelper.waitForFileContent), no change.Validation
Both .NET target frameworks (net8.0 + net472) build clean, and
ruff checkpasses on the Python file.