Skip to content
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

[GraphQL/Limits] BUGFIX: directives test error type #18661

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

amnn
Copy link
Contributor

@amnn amnn commented Jul 15, 2024

Description

Passing an unsupported directive should be a user input error, not an internal error.

Test plan

sui-graphql-e2e-tests$ cargo nextest run --features pg_integration -- limits/directives

Stack


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL: Passing an unsupported directive to the service is now treated as a BAD_USER_INPUT rather than an INTERNAL_SERVER_ERROR.
  • CLI:
  • Rust SDK:

@amnn amnn self-assigned this Jul 15, 2024
Copy link

vercel bot commented Jul 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2024 11:42am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jul 16, 2024 11:42am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jul 16, 2024 11:42am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Jul 16, 2024 11:42am

## Description

Passing an unsupported directive should be a user input error, not an
internal error.

## Test plan

CI
@amnn amnn merged commit 887812f into amnn/qlc-ext Jul 16, 2024
46 checks passed
@amnn amnn deleted the amnn/qlc-dir-err branch July 16, 2024 12:13
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Two header related clean-ups:

- The version header should no longer be part of the CORS configuration,
because we don't expect versions to be configured by (request) header.
- The `ShowUsage` type doesn't need to implement `Header` because we
only care about comparing its name.

## Test plan

CI

## Stack
- #18660
- #18661 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: `x-sui-rpc-version` is no longer an accepted request
header, as versions are now selected by modifying the path.
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
…18663)

## Description

This is a file order change only, with no other meaningful changes. It
standardises the order to:

- Constants
- Types
- Impls
- Trait Impls
- Free functions

## Test plan

CI

## Stack
- #18660
- #18661 
- #18662 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Trying to do the directive checks at the same time as the query checks
complicates both implementations. Split out the directive check into its
own extension.

Also fix the directive checks not looking at directives on variable
definitions.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run \
  --features pg_integration              \
  -- limits/directives.move
```

## Stack
- #18660
- #18661 
- #18662 
- #18663 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: The service now detects unsupported directives on query
variable definitions.
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Rewriting query limits checker to land a number of improvements and
fixes:

- Avoid issues with overflows by counting down from a predefined budget,
rather than counting up to the limit and protecting multiplications
using `checked_mul`.

- Improve detection of paginated fields: 
- Previously we treated all connections-related fields as appearing as
many times as the page size (including the field that introduced the
connection, and the `pageInfo` field). This was over-approximated the
output size by a large margin. The new approach counts exactly the
number of nodes in the output: The connection's root field, and any
non-`edges` or `nodes` field will not get multiplied by the page size.
- The checker now also detects connections-related fields even if they
are obscured by fragment or inline fragment spreads.

- Tighter `__schema` query detection: Previously we would skip requests
that started with a `__schema` introspection query. Now it's required to
be the only operation in the request (not just the first).

- Fix metrics collection after limits are hit: Previously, if a limit
was hit, we would not observe validation-related metrics in prometheus.
Now we will always record such metrics, and if a limit has been hit, it
will register as being "at" the limit.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run --features pg_integration -- limits/
```

## Stack

- #18660 
- #18661 
- #18662
- #18663 
- #18664 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: Output node estimation has been made more accurate -- the
estimate should now track the theoretical max number of nodes on the
JSON `data` output.
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Passing an unsupported directive should be a user input error, not an
internal error.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run --features pg_integration -- limits/directives
```

## Stack
- #18660

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: Passing an unsupported directive to the service will be
treated as a `BAD_USER_INPUT` rather than an `INTERNAL_SERVER_ERROR`.
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Two header related clean-ups:

- The version header should no longer be part of the CORS configuration,
because we don't expect versions to be configured by (request) header.
- The `ShowUsage` type doesn't need to implement `Header` because we
only care about comparing its name.

## Test plan

CI

## Stack
- #18660
- #18661 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: `x-sui-rpc-version` is no longer an accepted request
header, as versions are now selected by modifying the path.
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
…18663)

## Description

This is a file order change only, with no other meaningful changes. It
standardises the order to:

- Constants
- Types
- Impls
- Trait Impls
- Free functions

## Test plan

CI

## Stack
- #18660
- #18661 
- #18662 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Trying to do the directive checks at the same time as the query checks
complicates both implementations. Split out the directive check into its
own extension.

Also fix the directive checks not looking at directives on variable
definitions.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run \
  --features pg_integration              \
  -- limits/directives.move
```

## Stack
- #18660
- #18661 
- #18662 
- #18663 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: The service now detects unsupported directives on query
variable definitions.
- [ ] CLI: 
- [ ] Rust SDK:
amnn added a commit that referenced this pull request Jul 16, 2024
## Description

Rewriting query limits checker to land a number of improvements and
fixes:

- Avoid issues with overflows by counting down from a predefined budget,
rather than counting up to the limit and protecting multiplications
using `checked_mul`.

- Improve detection of paginated fields: 
- Previously we treated all connections-related fields as appearing as
many times as the page size (including the field that introduced the
connection, and the `pageInfo` field). This was over-approximated the
output size by a large margin. The new approach counts exactly the
number of nodes in the output: The connection's root field, and any
non-`edges` or `nodes` field will not get multiplied by the page size.
- The checker now also detects connections-related fields even if they
are obscured by fragment or inline fragment spreads.

- Tighter `__schema` query detection: Previously we would skip requests
that started with a `__schema` introspection query. Now it's required to
be the only operation in the request (not just the first).

- Fix metrics collection after limits are hit: Previously, if a limit
was hit, we would not observe validation-related metrics in prometheus.
Now we will always record such metrics, and if a limit has been hit, it
will register as being "at" the limit.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run --features pg_integration -- limits/
```

## Stack

- #18660 
- #18661 
- #18662
- #18663 
- #18664 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: Output node estimation has been made more accurate -- the
estimate should now track the theoretical max number of nodes on the
JSON `data` output.
- [ ] CLI: 
- [ ] Rust SDK:
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
## Description

Passing an unsupported directive should be a user input error, not an
internal error.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run --features pg_integration -- limits/directives
```

## Stack
- MystenLabs#18660

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: Passing an unsupported directive to the service will be
treated as a `BAD_USER_INPUT` rather than an `INTERNAL_SERVER_ERROR`.
- [ ] CLI: 
- [ ] Rust SDK:
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
## Description

Two header related clean-ups:

- The version header should no longer be part of the CORS configuration,
because we don't expect versions to be configured by (request) header.
- The `ShowUsage` type doesn't need to implement `Header` because we
only care about comparing its name.

## Test plan

CI

## Stack
- MystenLabs#18660
- MystenLabs#18661 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: `x-sui-rpc-version` is no longer an accepted request
header, as versions are now selected by modifying the path.
- [ ] CLI: 
- [ ] Rust SDK:
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
…ystenLabs#18663)

## Description

This is a file order change only, with no other meaningful changes. It
standardises the order to:

- Constants
- Types
- Impls
- Trait Impls
- Free functions

## Test plan

CI

## Stack
- MystenLabs#18660
- MystenLabs#18661 
- MystenLabs#18662 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
## Description

Trying to do the directive checks at the same time as the query checks
complicates both implementations. Split out the directive check into its
own extension.

Also fix the directive checks not looking at directives on variable
definitions.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run \
  --features pg_integration              \
  -- limits/directives.move
```

## Stack
- MystenLabs#18660
- MystenLabs#18661 
- MystenLabs#18662 
- MystenLabs#18663 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: The service now detects unsupported directives on query
variable definitions.
- [ ] CLI: 
- [ ] Rust SDK:
tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
## Description

Rewriting query limits checker to land a number of improvements and
fixes:

- Avoid issues with overflows by counting down from a predefined budget,
rather than counting up to the limit and protecting multiplications
using `checked_mul`.

- Improve detection of paginated fields: 
- Previously we treated all connections-related fields as appearing as
many times as the page size (including the field that introduced the
connection, and the `pageInfo` field). This was over-approximated the
output size by a large margin. The new approach counts exactly the
number of nodes in the output: The connection's root field, and any
non-`edges` or `nodes` field will not get multiplied by the page size.
- The checker now also detects connections-related fields even if they
are obscured by fragment or inline fragment spreads.

- Tighter `__schema` query detection: Previously we would skip requests
that started with a `__schema` introspection query. Now it's required to
be the only operation in the request (not just the first).

- Fix metrics collection after limits are hit: Previously, if a limit
was hit, we would not observe validation-related metrics in prometheus.
Now we will always record such metrics, and if a limit has been hit, it
will register as being "at" the limit.

## Test plan

```
sui-graphql-e2e-tests$ cargo nextest run --features pg_integration -- limits/
```

## Stack

- MystenLabs#18660 
- MystenLabs#18661 
- MystenLabs#18662
- MystenLabs#18663 
- MystenLabs#18664 

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [x] GraphQL: Output node estimation has been made more accurate -- the
estimate should now track the theoretical max number of nodes on the
JSON `data` output.
- [ ] CLI: 
- [ ] Rust SDK:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants