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

Propagate API server error metadata to GraphQL callers #65

Merged
merged 1 commit into from
May 13, 2021
Merged

Propagate API server error metadata to GraphQL callers #65

merged 1 commit into from
May 13, 2021

Conversation

negz
Copy link
Member

@negz negz commented May 13, 2021

Description of your changes

This decorates GraphQL errors with a source (either the API server, or unknown). If the error comes from the API server, we bubble up the code/reason for the error, according to the API server.

I have:

  • Read and followed xgql's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

I've tested a few failure cases to ensure we have the error extensions we expect:

Creating a Secret in a non-existent namespace:

{
  "errors": [
    {
      "message": "cannot create Kubernetes resource: namespaces \"wat\" not found",
      "path": [
        "createKubernetesResource"
      ],
      "extensions": {
        "code": 404,
        "reason": "NotFound",
        "source": "APIServer"
      }
    }
  ],
  "data": null,
  "extensions": {}
}

Creating a Bucket with no spec:

{
  "errors": [
    {
      "message": "cannot create Kubernetes resource: Bucket.storage.gcp.crossplane.io \"test\" is invalid: spec: Required value",
      "path": [
        "createKubernetesResource"
      ],
      "extensions": {
        "code": 422,
        "reason": "Invalid",
        "source": "APIServer"
      }
    }
  ],
  "data": null,
  "extensions": {}
}

This decorates GraphQL errors with a source (either the API server, or unknown).
If the error comes from the API server, we bubble up the code/reason for the
error, according to the API server.

Signed-off-by: Nic Cope <negz@rk0n.org>
@negz negz requested review from thephred and hasheddan May 13, 2021 22:12
@cla-bot cla-bot bot added the cla-signed label May 13, 2021
@negz negz merged commit 5d99b6b into upbound:main May 13, 2021
@negz negz deleted the whyyoubreak branch May 13, 2021 22:16
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.

1 participant