w3c / wot-discovery

Repository for WoT discovery discussion
https://w3c.github.io/wot-discovery/
Other
20 stars 17 forks source link

Definition of Problem Details error types #150

Open farshidtz opened 3 years ago

farshidtz commented 3 years ago

The directory uses RFC7807 Problem Details for error responses.

Example Problem Details taken from RFC7807:

{
    "type": "https://example.com/probs/out-of-credit",
    "title": "You do not have enough credit.",
    "detail": "Your current balance is 30, but that costs 50.",
    "instance": "/account/12345/msgs/abc",
    ...
}

For now, the discovery spec omits type which defaults to "about:blank" and in this case title should be set to HTTP status text. Example validation error from the wot-discovery/#validation:

{
    "title": "Bad Request",
    "status": 400,
    "detail": "The input did not pass the JSON Schema validation",
    "instance": "/errors/30585584-cce2-4d04-8079-67b33ffdafbc",
    "validationErrors": [
        {
            "field": "(root)",
            "description": "security is required"
        },
        {
            "field": "properties.status.forms.0.href",
            "description": "Invalid type. Expected: string, given: integer"
        }
    ]
}

The Problem Details error type field is a URI reference. From RFC7807:

A URI reference that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type

We could use type to map the occurred error to a WoT-specific error class. Other WoT TFs have also raised the lack of WoT-specific error types:

I think the discovery spec may be the right place to define error types. Example types could be:

We could have a Errors section in the spec with subsection for each of the above to provide further description and examples. With the equivalent section ids, the above URLs will anchor at the right subsection.

mmccool commented 3 years ago
mmccool commented 3 years ago

@farshidtz will make a PR

mmccool commented 3 years ago

Why is this labelled a stretch goal? Should we not aim for 1.0 with this? Adding "Discuss" label, will put it in that category for the F2F.