Repository navigation
Fix undefined union member type crash in mutable schema parser - #10274
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves schema parsing and Fusion composition error handling by converting previously crashy/misleading failure modes (missing root types / missing union member types) into consistent SchemaInitializationExceptions, and by scoping composition logging so a previously-failed schema on a shared CompositionLog doesn’t prevent later schemas from being parsed/preprocessed/validated.
Changes:
- Add root type resolution and union member resolution guards in
SchemaParserto throw deterministic initialization errors instead of crashing or misclassifying missing types. - Introduce
ScopedCompositionLogand update Fusion parser/preprocessor to rely on per-schema scoped errors rather than the shared parent log’sHasErrors. - Add/extend tests in Mutable + Fusion to cover undefined root types, undefined union member types, and “earlier schema failed on shared log” scenarios.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaParserTests.cs | Adds regression tests for undefined root types and union member types. |
| src/HotChocolate/Mutable/src/Types.Mutable/Serialization/SchemaParser.cs | Resolves root types safely and validates union member types, throwing specific initialization exceptions. |
| src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.resx | Adds new localized messages for root type/union member missing or invalid. |
| src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.Designer.cs | Regenerates resource accessors for the new messages. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaPreprocessorTests.cs | Adds test ensuring preprocessing succeeds for later schema despite earlier shared-log failure. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaParserTests.cs | Adds tests for undefined root/union member types + shared-log failure behavior. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SchemaComposerTests.cs | Adds test asserting only the invalid schema is reported when a valid schema follows it. |
| src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaPreprocessor.cs | Uses scoped log to avoid earlier shared-log errors forcing current preprocessing to fail. |
| src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaParser.cs | Uses scoped log so parsing/validation isn’t blocked by prior schemas’ errors in a shared log. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Logging/ScopedCompositionLog.cs | New wrapper log that forwards to parent while tracking scoped entries and scoped HasErrors. |
Files not reviewed (1)
- src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.Designer.cs: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+556
to
+560
| Assert.Equal( | ||
| "Invalid GraphQL in source schema. Exception message: " | ||
| + "The query root type 'Query' is not defined..", | ||
| entry.Message); | ||
| Assert.Equal("A", entry.Schema?.Name); |
Comment on lines
+634
to
+638
| Assert.Equal( | ||
| "Invalid GraphQL in source schema. Exception message: " | ||
| + "The Union type 'Thing' cannot include the undefined type 'Widget'..", | ||
| entry.Message); | ||
| Assert.Equal("A", entry.Schema?.Name); |
Comment on lines
+1192
to
+1201
| // assert | ||
| Assert.True(result.IsFailure); | ||
| var error = Assert.Single(result.Errors); | ||
| Assert.Equal("Source schema parsing failed.", error.Message); | ||
| var entry = Assert.Single(log); | ||
| Assert.Equal("A", entry.Schema?.Name); | ||
| Assert.Equal( | ||
| "Invalid GraphQL in source schema. Exception message: " | ||
| + "The query root type 'Query' is not defined..", | ||
| entry.Message); |
Comment on lines
+1198
to
+1201
| Assert.Equal( | ||
| "Invalid GraphQL in source schema. Exception message: " | ||
| + "The query root type 'Query' is not defined..", | ||
| entry.Message); |
Contributor
Patch coverage94.9% of changed lines covered (56/59)
Uncovered changed lines (JSON){
"sha": "06c9e83bde8e37734cc3ba1d08ac962a5637689e",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Composition/Logging/ScopedCompositionLog.cs", "ranges": [[16, 16], [33, 33]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaParser.cs", "ranges": [[96, 96]] }
]
}Project coverage: 56.0% (261536/466695 lines) |
This was referenced Aug 29, 2026
Merged
This was referenced Sep 7, 2026
Closed
Closed
Closed
This was referenced Sep 14, 2026
Closed
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#405
Closed
This was referenced Sep 21, 2026
Closed
Closed
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#410
Merged
This was referenced Oct 5, 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.
Fixes #10268