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

Extend response/error with item and reuse it for all the errors #52

Open
googleson78 opened this issue Jan 28, 2025 · 1 comment
Open

Comments

@googleson78
Copy link

From looking at response/error_*.yaml, it seems like pretty much all the errors have the fields of response/error.yaml, as well as an additional item field, which is left opaque to be extended in different endpoints. Could we not instead have a response/error_with_item.yaml which has the response/error.yaml fields + an item field, and reuse that for all the errors in different endpoints, so that there are not many different error types which are actually practically identical? It seems to me that this would be an easier way to organise things

@googleson78
Copy link
Author

Actually, this is not only a matter of convenience, but somewhat a matter of correctness.

Currently, this spec for the Agency api (references/agency.yaml):

paths:
  /telemetry:
    post:
      responses:
        "400":
          description: Bad request.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: ../models/response/bulk.yaml
                  - required:
                      - failures
                    properties:
                      failures:
                        minItems: 1
                        items:
                          properties:
                            item:
                              $ref: ../models/telemetry.yaml
                          oneOf:
                            - $ref: ../models/response/error_bad_param.yaml
                            - $ref: ../models/response/error_missing_param.yaml

is misleading. It specifies a oneOf describing two alternatives which the error format might take, but the two errors are structurally the same, so it doesn't really matter which one we specify. Not only does it not matter which one is specified, but it is also impossible to distinguish between them. Consider

{
  "item": <someTelemetry>,
  "error": "bla",
  "error_description": "bla",
  "error_details": ["bla"]
}

Is this a error_bad_param.yaml or is this a error_missing_param.yaml? It seems to me that it could be both.

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

No branches or pull requests

1 participant