-
Notifications
You must be signed in to change notification settings - Fork 340
fix: support opt-out of strict variable validation #8884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
89c2c81
fix: support opt-out of variable validation
carodewig db883cc
convert run_validation_warn_mode from macro to function
conwuegb 18b5fe2
Convert validation test macros to functions
conwuegb 1b62376
Update supergraph yaml snippet with strict_variable_validation
conwuegb f1b8570
Update full router yaml snippet with strict_variable_validation
conwuegb fce1933
Fix incorrect strict_variable_validation mode name
conwuegb 1e86ff2
Remove superflous test and update comments
conwuegb 320b934
Add explanation of strict_variable_validation config
conwuegb 3dd74fe
Add changeset
conwuegb 2adb9cc
doc: combine changesets for simplicity
carodewig cf0f48a
chore: refactor to use Mode rather than a new *Mode
carodewig 556f80c
chore: refactor, remove todos
carodewig ea0f4ed
chore: name tests in rstest
carodewig f334b15
chore: refactor tests for simplicity
carodewig 0c39399
chore: fix linter
carodewig 2dbc80b
chore: docs to align with style guide
carodewig afe9d3d
chore: document modes in code
carodewig aa36413
Merge branch 'dev' into caroline/router-1602
carodewig acd87c0
chore: remove unnecessary default
carodewig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ### Add config to opt-out of stricter variable validation ([PR #8884](https://github.com/apollographql/router/pull/8884)) | ||
|
|
||
| Variable validation will become **_stricter by default_** due to [PR#8821](https://github.com/apollographql/router/pull/8821). | ||
| This PR fixed a gap in variable validation whereby the presence of unknown fields on an input object variable were not causing a request error as they should have. | ||
|
|
||
| This stricter validation **_may cause breakages_** for customers. | ||
|
|
||
| To alleviate that potential pain point while customers update their variables to be compliant, this change introduces a router config option to retain the previous level of validation and issue a warning log instead of an error. | ||
|
|
||
| > [!WARNING] | ||
| > If you need to opt out, you must set the config option to `warn` instead. | ||
|
|
||
| Enabled: | ||
| ```yaml | ||
| supergraph: | ||
| strict_variable_validation: enforce | ||
| ``` | ||
|
|
||
| Disabled: | ||
| ```yaml | ||
| supergraph: | ||
| strict_variable_validation: warn | ||
| ``` | ||
|
|
||
| Docs have also been updated to reflect this change. | ||
|
|
||
| <!-- [ROUTER-1602] --> | ||
| --- | ||
|
|
||
| [ROUTER-1602]: https://apollographql.atlassian.net/browse/ROUTER-1602?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ | ||
|
|
||
| By [@carodewig](https://github.com/carodewig) and [@conwuegb](https://github.com/conwuegb) in https://github.com/apollographql/router/pull/8884 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ use self::subgraph::SubgraphConfiguration; | |
| use crate::ApolloRouterError; | ||
| use crate::cache::DEFAULT_CACHE_CAPACITY; | ||
| use crate::configuration::cooperative_cancellation::CooperativeCancellation; | ||
| use crate::configuration::mode::WarnOrEnforceMode; | ||
| use crate::graphql; | ||
| use crate::plugin::plugins; | ||
| use crate::plugins::chaos; | ||
|
|
@@ -743,6 +744,10 @@ pub(crate) struct Supergraph { | |
| /// Log a message if the client closes the connection before the response is sent. | ||
| /// Default: false. | ||
| pub(crate) experimental_log_on_broken_pipe: bool, | ||
|
|
||
| /// TODO(@caroline) docs | ||
| #[serde(default = "default_strict_variable_validation")] | ||
| pub(crate) strict_variable_validation: WarnOrEnforceMode, | ||
| } | ||
|
|
||
| const fn default_generate_query_fragments() -> bool { | ||
|
|
@@ -767,6 +772,7 @@ impl Supergraph { | |
| early_cancel: Option<bool>, | ||
| experimental_log_on_broken_pipe: Option<bool>, | ||
| insert_result_coercion_errors: Option<bool>, | ||
| strict_variable_validation: Option<WarnOrEnforceMode>, | ||
| ) -> Self { | ||
| Self { | ||
| listen: listen.unwrap_or_else(default_graphql_listen), | ||
|
|
@@ -781,6 +787,8 @@ impl Supergraph { | |
| early_cancel: early_cancel.unwrap_or_default(), | ||
| experimental_log_on_broken_pipe: experimental_log_on_broken_pipe.unwrap_or_default(), | ||
| enable_result_coercion_errors: insert_result_coercion_errors.unwrap_or_default(), | ||
| strict_variable_validation: strict_variable_validation | ||
| .unwrap_or_else(default_strict_variable_validation), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -800,6 +808,7 @@ impl Supergraph { | |
| early_cancel: Option<bool>, | ||
| experimental_log_on_broken_pipe: Option<bool>, | ||
| insert_result_coercion_errors: Option<bool>, | ||
| strict_variable_validation: Option<WarnOrEnforceMode>, | ||
| ) -> Self { | ||
| Self { | ||
| listen: listen.unwrap_or_else(test_listen), | ||
|
|
@@ -814,6 +823,8 @@ impl Supergraph { | |
| early_cancel: early_cancel.unwrap_or_default(), | ||
| experimental_log_on_broken_pipe: experimental_log_on_broken_pipe.unwrap_or_default(), | ||
| enable_result_coercion_errors: insert_result_coercion_errors.unwrap_or_default(), | ||
| strict_variable_validation: strict_variable_validation | ||
| .unwrap_or_else(default_strict_variable_validation), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1506,6 +1517,10 @@ fn default_connection_shutdown_timeout() -> Duration { | |
| Duration::from_secs(60) | ||
| } | ||
|
|
||
| fn default_strict_variable_validation() -> WarnOrEnforceMode { | ||
| WarnOrEnforceMode::Enforce | ||
| } | ||
|
Comment on lines
+1521
to
+1523
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. guessing an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, since we want each use of mode to potentially have different defaults! |
||
|
|
||
| #[derive(Clone, Debug, Default, Error, Display, Serialize, Deserialize, JsonSchema)] | ||
| #[serde(deny_unknown_fields, rename_all = "snake_case")] | ||
| pub(crate) enum BatchingMode { | ||
|
|
||
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronArinder, in the team discussion on this opt-out feature you mentioned that the changeset should be super clear that an action is required by the customer. Is this what you had in mind or could it be clearer?