Repository navigation
Validate that directive applications are on valid locations - #10277
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds schema-validation coverage to ensure directives are only applied at locations declared by their definitions, and updates eventing + Fusion Federation preprocessing so synthesized directives carry correct declared locations for validation.
Changes:
- Introduces
DirectiveIsInValidLocationRule(HCV0032) and registers it in the defaultSchemaValidatorrule set. - Extends
DirectiveEventto include the appliedDirectiveLocation, and updatesSchemaValidatorto publish directive events with explicit locations. - Updates Fusion Apollo Federation transformations to attach synthesized directive applications to
FusionBuiltIns.SourceSchemaDirectivesdefinitions (instead of placeholder directive definitions).
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Fusion/src/Fusion.Composition/ApolloFederation/TransformRequiresToRequire.cs | Uses built-in directive definitions for synthesized @require / @external applications so declared locations are available during validation. |
| src/HotChocolate/Fusion/src/Fusion.Composition/ApolloFederation/GenerateLookupFields.cs | Uses built-in directive definitions for synthesized @internal, @lookup, @is, @shareable applications. |
| src/HotChocolate/Core/test/Types.Validation.Tests/SchemaValidatorTests.cs | Updates default-rule registration expectations to include the new rule. |
| src/HotChocolate/Core/test/Types.Validation.Tests/Rules/DirectiveIsInValidLocationRuleTests.cs | Adds targeted tests for valid/invalid directive placement across type-system locations. |
| src/HotChocolate/Core/src/Types.Validation/SchemaValidator.cs | Publishes DirectiveEvent with explicit directive application locations across schema members. |
| src/HotChocolate/Core/src/Types.Validation/Rules/DirectiveIsUniqueRule.cs | Updates directive-event deconstruction to account for the new location payload. |
| src/HotChocolate/Core/src/Types.Validation/Rules/DirectiveIsInValidLocationRule.cs | Adds the new validation rule that emits HCV0032 for invalid directive application locations. |
| src/HotChocolate/Core/src/Types.Validation/Rules/DirectiveIsDefinedRule.cs | Updates directive-event deconstruction to account for the new location payload. |
| src/HotChocolate/Core/src/Types.Validation/Properties/ValidationResources.resx | Adds localized resource string for the new HCV0032 message. |
| src/HotChocolate/Core/src/Types.Validation/Properties/ValidationResources.Designer.cs | Regenerates resource accessor for the new message string. |
| src/HotChocolate/Core/src/Types.Validation/Logging/LogEntryHelper.cs | Adds log entry builder for “directive in invalid location” (HCV0032). |
| src/HotChocolate/Core/src/Types.Validation/Logging/LogEntryCodes.cs | Adds HCV0032 constant. |
| src/HotChocolate/Core/src/Types.Validation/Events/ValidationEvents.cs | Extends DirectiveEvent with DirectiveLocation to support location-aware rules. |
Files not reviewed (1)
- src/HotChocolate/Core/src/Types.Validation/Properties/ValidationResources.Designer.cs: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Patch coverage98.6% of changed lines covered (71/72)
Uncovered changed lines (JSON){
"sha": "4a70274a152721b49e3e1e7e99f724a2fa1a91b3",
"files": [
{ "path": "src/HotChocolate/Core/src/Types.Validation/SchemaValidator.cs", "ranges": [[252, 252]] }
]
}Project coverage: 56.3% (264451/470033 lines) |
This was referenced Aug 29, 2026
Merged
This was referenced Sep 8, 2026
Closed
Closed
This was referenced Sep 15, 2026
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#405
Closed
Closed
This was referenced Sep 22, 2026
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
Open
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.
Summary
DirectiveIsInValidLocationRuletoHotChocolate.Types.Validation: a directive application at a location its definition does not declare is now reported asHCV0032. Applications without a definition are skipped, sinceDirectiveIsDefinedRulealready reports those.DirectiveEventnow carries theDirectiveLocationat which the directive is applied, supplied bySchemaValidatorat each publish site, since the location cannot be inferred from the member alone (arguments and input fields are bothIInputValueDefinition). This is a breaking change to the publicDirectiveEventrecord struct.@internal,@lookup,@is,@shareable,@require, and@externalapplications to theFusionBuiltIns.SourceSchemaDirectivesdefinitions instead of detached placeholder definitions, so the applications carry the declared locations the new rule checks.Test plan
DirectiveIsInValidLocationRuleTestswith a failing case per type-system location (schema, scalar, object, interface, union, enum, enum value, input object, input field, field, field argument, directive definition, and directive-definition argument), plus declared-locations, repeatable, and undefined-directive controls.dotnet test src/HotChocolate/Core/test/Types.Validation.Tests: 632/632 pass.dotnet test src/HotChocolate/Fusion/test/Fusion.Composition.Tests: 3160/3160 pass.