OData / OData/AspNetCoreOData

Samples do not generate compliant OData Error responses

Open
#511 2 comments 0 reactions 2 assignees View on GitHub

@xuzhg is already working on this.

Since Mar 8, 2022.

Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

The samples tend to use IActionResult return types, which put error messages in the value property, or don't provide an error message at all instead relying solely on an HTTP status code. This does not adhere to the OData Error specification. In particular:

  • The error response MUST be a single JSON object. This object MUST have a single name/value pair named error. The value must be a JSON object.
  • This object MUST contain name/value pairs with the names code and message, and it MAY contain name/value pairs with the names target, details and innererror.

As a result, consumers that do adhere to the spec are not able to show error messages.

Examples of non-compliant responses:

No payload (error object omitted):
https://github.com/OData/AspNetCoreOData/blob/38338c0c38e219798446d62cb72277bca2675bb7/sample/ODataDynamicModel/Controllers/HandleAllController.cs#L93

Error object omitted, message in value:
https://github.com/OData/AspNetCoreOData/blob/38338c0c38e219798446d62cb72277bca2675bb7/sample/ODataDynamicModel/Controllers/HandleAllController.cs#L108

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.