Skip to content

Improve Schema Error Details#9838

Merged
michaelstaib merged 2 commits into
mainfrom
mst/improve-errors
Jun 3, 2026
Merged

Improve Schema Error Details#9838
michaelstaib merged 2 commits into
mainfrom
mst/improve-errors

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

@michaelstaib michaelstaib commented Jun 3, 2026

Fixes #9546

Copilot AI review requested due to automatic review settings June 3, 2026 14:22
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

This PR improves schema discovery error diagnostics by adding a developer-facing “type inference path” that explains how an unresolved type reference was reached during type discovery, and by exposing that path in a structured error extension.

Changes:

  • Add TypeInferencePathBuilder to build a root-to-leaf member chain for unresolved type references (short + namespace-qualified renderings, with truncation).
  • Enhance TypeDiscoverer.CollectErrors() to append the short path to the error message and include the expanded path in error.Extensions["typePath"].
  • Add/adjust tests and snapshot baselines to validate path formatting, truncation, and the new extension.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/HotChocolate/Core/src/Types/Configuration/TypeDiscoverer.cs Formats unresolved-type errors deterministically and enriches them with a computed type inference path (message + extension).
src/HotChocolate/Core/src/Types/Configuration/TypeInferencePathBuilder.cs New helper to locate and render member chains leading to a target TypeReference, including truncation and friendly type-name formatting.
src/HotChocolate/Core/src/Types/TypeErrorFields.cs Adds the typePath extension key constant.
src/HotChocolate/Core/test/Types.Tests/Configuration/TypeDiscovererTests.cs Adds tests for message path inclusion, typePath extension, friendly generic naming, and truncation behavior.
src/HotChocolate/Core/test/Types.Tests/Configuration/__snapshots__/TypeDiscovererTests.DiscoverTypes_Should_Append_PathToRoot_When_Nested_Member_Cannot_Be_Inferred.snap New snapshot baseline for the enhanced error message format.
src/HotChocolate/Core/test/Types.Tests/Configuration/__snapshots__/TypeDiscovererTests.Cannot_Infer_Input_Type.snap Updates snapshot baseline to reflect the new multi-line message with appended inference path.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need drastic improvement to "Unable to infer or resolve a schema type from the type reference" error information

2 participants