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

How prescriptive should we be about which HTTP error codes to return? #100

Open
duglin opened this issue Apr 24, 2024 · 7 comments
Open
Assignees
Labels
AddToSpec v1 Required to be resolved for v1

Comments

@duglin
Copy link
Contributor

duglin commented Apr 24, 2024

404 is one we do mandate, and we sometimes say it must be a 400, but most of the time we just say "an error must be generated". Do we need to be more precise? Should we standardize the error messages?

@duglin duglin added the v1 Required to be resolved for v1 label Apr 24, 2024
@duglin duglin changed the title How proscriptive should we be about which HTTP error codes to return? How prescriptive should we be about which HTTP error codes to return? Apr 24, 2024
@duglin
Copy link
Contributor Author

duglin commented May 24, 2024

@manuelottlik
Copy link
Contributor

We need to provide a way to standardize the non-happy path in an extensible way.

@duglin
Copy link
Contributor Author

duglin commented May 31, 2024

Proposal:

  • Define the http response code for each error - MUST use these
  • Define the problem/json for each error - MUST use these if they advertise they support problem/json
  • Define a capability so people can advertise if they expose problem/json or not ("not" is for s3-like usecases)
  • Impls can add extension attributes to the spec defined problems
  • Impls can add extension problems (custom "type") for non-spec-defined error situations
  • Add the ability to expose a URL so clients can retrieve the list of errors supports + extensions they support

@duglin
Copy link
Contributor Author

duglin commented Feb 5, 2025

Need:

  • make sure each error has the proper HTTP response code
  • make sure each error has the RFC9457 fields (we want to use) defined

@duglin
Copy link
Contributor Author

duglin commented Feb 5, 2025

@manuelottlik will work on a template to follow for the spec text/ "errors" appendix

@manuelottlik
Copy link
Contributor

manuelottlik commented Feb 20, 2025

This would be a very simple problem for a 404:

{
  "type": "https://docs.xregistry.io/problems/default/not-found-error",
  "instance": "/schemagroups/mygroup/schemas/myschema",
  "title": "Not Found"
}

This could be a more advanced problem that has an additional attribute compatibility in its body to give problem relevant information to the client:

{
  "type": "https://docs.xregistry.io/problems/compatibility-violated",
  "instance": "schemagroups/mygroup/schemas/myschema/versions",
  "title": "Compatibility violated",
  "detail": "Can not create version because it violates the compatibility",
  "compatibility": "forward_transitive"
}

This would be a JSON schema representation we can use in our OpenAPI:

DefaultProblem:
  type: object
  description: default problem object thrown when no further problem is specified
  required:
    - type
    - status
    - title
  properties:
    status:
      type: integer
      format: int32
      description: HTTP status code
      example: 400
    type:
      type: string
      format: url
      description: URI pointing to a human readable documentation
      example: https://docs.xregistry.io/problems/email-already-taken
    title:
      type: string
      description: short, human readable description of the problem
      example: The provided e-mail address is already taken.
    detail:
      type: string
      description: human readable explanation of the problem
      example: The e-mail adress serves as an identifier and thus can only be taken once.
    instance:
      type: string
      description: endpoint where the problem occurred
      example: /users

I copied these things from a personal project of mine and adapted them to xRegistry. The reason for the camelCase titles is i18n, since clients might want to use that.

@manuelottlik manuelottlik self-assigned this Feb 21, 2025
@duglin
Copy link
Contributor Author

duglin commented Mar 6, 2025

https://datatracker.ietf.org/doc/html/rfc9457#section-3.1.5

"instance" is kind of interesting. As defined it looks like it's a URL to the "problem json" and not the instance/object that generated the error. So when you used schemagroups/mygroup/schemas/myschema/versions I'm not sure that's correct. However, I would prefer to use it as you're using it... meaning, the "thing that we were processing". Think that's ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AddToSpec v1 Required to be resolved for v1
Projects
None yet
Development

No branches or pull requests

2 participants