500 Internal Server Error is the HTTP status for an unexpected failure on the provider’s side. Every API operation needs this error output: even a valid request can fail because of an implementation problem or unavailable infrastructure. section 4.5.9 section 4.9
Choose the status according to what went wrong:
- Use 400 Bad Request for missing or invalid input, not for an unexpected server failure. section 4.5.10
- Use 404 Not Found when a resource identified by a path parameter cannot be found. section 4.5.10
- Include 500 Internal Server Error among the documented outputs of every operation. section 4.5.9
An error without a disclosure
Suppose a database connection fails. A 500 response should not expose a database error code, server IP address, or database engine. Return a generic message instead. If investigation needs a reference, a Problem Details response can include an opaque `instance` URI such as `/unexpected-errors/12345`; the reference can also appear in the message shown to the consumer. section 12.10.3
When documenting an operation in OpenAPI, check that its 500 response is present and that its message reveals no sensitive implementation details. A reference can help investigate the occurrence without exposing the underlying failure. section 12.10 section 12.10.3

