Skip to content

Commit

Permalink
feat: update to redact_subgraph_errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sjin committed Nov 27, 2024
1 parent 5bd015c commit 248599c
Show file tree
Hide file tree
Showing 31 changed files with 1,267 additions and 982 deletions.
2,093 changes: 1,189 additions & 904 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apollo-router/src/batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ mod tests {
let schema = include_str!("../tests/fixtures/batching/schema.graphql");
let service = TestHarness::builder()
.configuration_json(serde_json::json!({
"include_subgraph_errors": {
"all": true
"redact_subgraph_errors": {
"all": false
},
"batching": {
"enabled": true,
Expand Down
8 changes: 4 additions & 4 deletions apollo-router/src/plugins/authorization/authenticated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1914,8 +1914,8 @@ mod tests {
"supergraph": {
"introspection": true
},
"include_subgraph_errors": {
"all": true
"redact_subgraph_errors": {
"all": false
},
"authorization": {
"directives": {
Expand Down Expand Up @@ -1972,8 +1972,8 @@ mod tests {
"supergraph": {
"introspection": true
},
"include_subgraph_errors": {
"all": true
"redact_subgraph_errors": {
"all": false
},
"authorization": {
"directives": {
Expand Down
14 changes: 7 additions & 7 deletions apollo-router/src/plugins/cache/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ async fn no_data() {
.unwrap();

let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache)
Expand Down Expand Up @@ -648,7 +648,7 @@ async fn no_data() {
);

let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache)
Expand Down Expand Up @@ -772,7 +772,7 @@ async fn missing_entities() {
.unwrap();

let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache)
Expand Down Expand Up @@ -833,7 +833,7 @@ async fn missing_entities() {
].into_iter().collect());

let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache)
Expand Down Expand Up @@ -896,7 +896,7 @@ async fn invalidate() {
let mut invalidation = entity_cache.invalidation.clone();
let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache.clone())
Expand All @@ -919,7 +919,7 @@ async fn invalidate() {
// Now testing without any mock subgraphs, all the data should come from the cache
let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache.clone())
Expand Down Expand Up @@ -950,7 +950,7 @@ async fn invalidate() {
panic!();
let service = TestHarness::builder()
.configuration_json(serde_json::json!({"include_subgraph_errors": { "all": true } }))
.configuration_json(serde_json::json!({"redact_subgraph_errors": { "all": false } }))
.unwrap()
.schema(SCHEMA)
.extra_plugin(entity_cache)
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/tests/fixtures/batching/subgraph_id.router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ rhai:
scripts: ./tests/fixtures/batching
main: subgraph_id.rhai

include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
4 changes: 2 additions & 2 deletions apollo-router/tests/integration/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ async fn make_request(request: Request) -> apollo_router::graphql::Response {
"supergraph": {
"introspection": true,
},
"include_subgraph_errors": {
"all": true,
"redact_subgraph_errors": {
"all": false,
},
}))
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/tests/integration/operation_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ async fn incorrect_operation_name() {
async fn make_request(request: Request) -> apollo_router::graphql::Response {
apollo_router::TestHarness::builder()
.configuration_json(json!({
"include_subgraph_errors": {
"all": true,
"redact_subgraph_errors": {
"all": false,
},
}))
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/tests/integration/subgraph_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use wiremock::ResponseTemplate;
use crate::integration::IntegrationTest;

const CONFIG: &str = r#"
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
"#;

#[tokio::test(flavor = "multi_thread")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ telemetry:

override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
8 changes: 4 additions & 4 deletions apollo-router/tests/integration/traffic_shaping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ async fn test_subgraph_timeout() -> Result<(), BoxError> {
.config(format!(
r#"
{PROMETHEUS_CONFIG}
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
traffic_shaping:
all:
timeout: 1ns
Expand Down Expand Up @@ -201,8 +201,8 @@ async fn test_subgraph_rate_limit() -> Result<(), BoxError> {
.config(format!(
r#"
{PROMETHEUS_CONFIG}
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
traffic_shaping:
all:
global_rate_limit:
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/tests/integration/typename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ async fn two_named_operations() {
async fn make_request(request: Request) -> apollo_router::graphql::Response {
apollo_router::TestHarness::builder()
.configuration_json(json!({
"include_subgraph_errors": {
"all": true,
"redact_subgraph_errors": {
"all": false,
},
}))
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

plugins:
experimental.expose_query_plan: true
4 changes: 2 additions & 2 deletions apollo-router/tests/samples/core/defer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
4 changes: 2 additions & 2 deletions apollo-router/tests/samples/core/query1/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
4 changes: 2 additions & 2 deletions apollo-router/tests/samples/core/query2/configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

preview_entity_cache:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

preview_entity_cache:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

preview_entity_cache:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

preview_entity_cache:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

rhai:
scripts: "tests/samples/enterprise/entity-cache/private"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

telemetry:
exporters:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

telemetry:
exporters:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

supergraph:
query_planning:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

supergraph:
query_planning:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
override_subgraph_url:
products: http://localhost:4005
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false

supergraph:
query_planning:
Expand Down
8 changes: 4 additions & 4 deletions apollo-router/tests/set_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ fn get_configuration(rust_qp: bool) -> serde_json::Value {
"plugins": {
"experimental.expose_query_plan": true
},
"include_subgraph_errors": {
"all": true
"redact_subgraph_errors": {
"all": false
},
"supergraph": {
// TODO(@goto-bus-stop): need to update the mocks and remove this, #6013
Expand All @@ -56,8 +56,8 @@ fn get_configuration(rust_qp: bool) -> serde_json::Value {
"plugins": {
"experimental.expose_query_plan": true
},
"include_subgraph_errors": {
"all": true
"redact_subgraph_errors": {
"all": false
},
"supergraph": {
// TODO(@goto-bus-stop): need to update the mocks and remove this, #6013
Expand Down
8 changes: 4 additions & 4 deletions docs/source/routing/cloud/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,13 @@ Subgraph errors redacted

This redaction prevents potential leaks of sensitive information to clients.

If you instead want to propagate subgraph errors to clients, you can add the `include_subgraph_errors` key to your router's YAML configuration, like so:
If you instead want to propagate subgraph errors to clients, you can add the `redact_subgraph_errors` key to your router's YAML configuration, like so:

```yaml
include_subgraph_errors:
all: true # Propagate errors from all subraphs
redact_subgraph_errors:
all: false # Propagate errors from all subraphs
subgraphs:
products: false # Do not propagate errors from the products subgraph
products: true # Do not propagate errors from the products subgraph
```

Any configuration under the `subgraphs` key takes precedence over configuration under the `all` key. In the example above, subgraph errors are included from all subgraphs except the `products` subgraph.
Expand Down
6 changes: 3 additions & 3 deletions docs/source/routing/cloud/lattice-troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ To help resolve AWS VPC Lattice connection issues, enable subgraph error inclusi
4. In **Router configuration YAML**, ensure your configuration has the following configuration block:

```yaml
include_subgraph_errors:
all: true
redact_subgraph_errors:
all: false
```
5. Click the **Save** button in the top right corner of that section.
Configuration changes trigger a new launch. Please wait a few minutes for your cloud router to update with this new configuration. You can track your graph variant's deployment status on its **Launches** page.
Once you've found and resolved the issue, Apollo recommends turning off subgraph error inclusion. To do so, remove the `include_subgraph_errors` configuration. Then, save the router's configuration YAML.
Once you've found and resolved the issue, Apollo recommends turning off subgraph error inclusion. To do so, remove the `redact_subgraph_errors` configuration. Then, save the router's configuration YAML.

## Common issues and errors

Expand Down
12 changes: 6 additions & 6 deletions docs/source/routing/observability/subgraph-error-inclusion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ By default, a GraphOS Router or Apollo Router Core redacts the details of subgra
Subgraph errors redacted
```

This redaction prevents potential leaks of sensitive information to the client. Using the `include_subgraph_errors` plugin, you can configure the router to propagate subgraph errors to clients instead. You can do this for all subgraphs, or on a per-subgraph basis.
This redaction prevents potential leaks of sensitive information to the client. Using the `redact_subgraph_errors` plugin, you can configure the router to propagate subgraph errors to clients instead. You can do this for all subgraphs, or on a per-subgraph basis.

## Configuration

To configure subgraph error inclusion, add the `include_subgraph_errors` plugin to your [YAML config file](/router/configuration/overview/#yaml-config-file), like so:
To configure subgraph error inclusion, add the `redact_subgraph_errors` plugin to your [YAML config file](/router/configuration/overview/#yaml-config-file), like so:

```yaml title="router.yaml"
include_subgraph_errors:
all: true # Propagate errors from all subgraphs
redact_subgraph_errors:
all: false # Propagate errors from all subgraphs
subgraphs:
products: false # Do not propagate errors from the products subgraph
products: true # Do not propagate errors from the products subgraph
```
Any configuration under the `subgraphs` key takes precedence over configuration under the `all` key. In the example above, subgraph errors are included from all subgraphs _except_ the `products` subgraph.
Expand All @@ -32,7 +32,7 @@ To report the subgraph errors to GraphOS that is a separate configuration that i
To log the GraphQL error responses (i.e. messages returned in the GraphQL `errors` array) from the router, see the [logging configuration documentation](/router/configuration/telemetry/exporters/logging/overview).

## Exposing subgraph name through error extensions
If `include_subgraph_errors` is `true` for a particular subgraph, all errors originating in this subgraph will have the subgraph's name exposed as a `service` extension.
If `redact_subgraph_errors` is `false` for a particular subgraph, all errors originating in this subgraph will have the subgraph's name exposed as a `service` extension.

For example, if subgraph errors are enabled for the `products` subgraph and this subgraph returns an error, it will have a `service` extension:
```json
Expand Down
Loading

0 comments on commit 248599c

Please sign in to comment.