Repository navigation
Fix Utf8MemoryBuilder state after sealing or abandoning - #10378
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is small and localized, and the added tests/snapshot directly validate the intended sealed/abandoned behavior and content preservation.
Pull request overview
This PR fixes Utf8MemoryBuilder’s internal state transitions so the builder is correctly treated as sealed after calling Seal() or Abandon(), preventing further use of write-related state (like NextIndex) while still preserving the sealed output.
Changes:
- Set
_written = -1afterSeal()andAbandon()to consistently mark the builder as sealed/unusable. - Add unit tests verifying
NextIndexthrows after sealing/abandoning and that sealing preserves previously written content. - Add a Markdown snapshot to validate sealed content (
WrittenSpan,WrittenMemory, and previously returned segment) remains consistent.
File summaries
| File | Description |
|---|---|
| src/HotChocolate/Language/src/Language.Utf8/Utf8MemoryBuilder.cs | Marks the builder as sealed after Seal()/Abandon() by setting _written = -1. |
| src/HotChocolate/Language/test/Language.Tests/Parser/Utf8MemoryBuilderTests.cs | Adds regression tests for sealed/abandoned behavior and for content preservation after sealing. |
| src/HotChocolate/Language/test/Language.Tests/Parser/snapshots/Utf8MemoryBuilderTests.Seal_Should_PreserveWrittenContent_When_BufferContainsData.md | Adds snapshot coverage for preserved sealed content. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Patch coverage100.0% of changed lines covered (2/2)
Project coverage: 57.9% (288209/497788 lines) |
glen-84
pushed a commit
that referenced
this pull request
Sep 23, 2026
This was referenced Sep 26, 2026
Merged
This was referenced Oct 3, 2026
Open
This was referenced Oct 7, 2026
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.
No description provided.