FM-025 Authorization, Localization, and HTTP Semantics

Incorrect HTTP Status and Business-Error Semantics

HTTP 200 returned when a business operation was rejected; consumers misinterpret failures as success.

Failure explanation

An API’s HTTP status code contradicts the actual outcome represented by the body or business state. Returning 200 for a rejected payment, failed transfer, or invalid operation can cause generated clients, monitoring, and consumers to record false success. Conversely, returning an error status after a committed operation can encourage unsafe retries. Status semantics and business outcome must be designed together.

Example

POST /transfers returns HTTP 200 with {"result":"REJECTED","reason":"ACCOUNT_CLOSED"}. A client checks only the 2xx status and marks the transfer as successful.

How to test

  • Exercise success, validation rejection, authentication failure, authorization failure, conflict, not-found, throttling, and server failure.
  • Compare HTTP status, body code, and resulting business state.
  • Simulate a committed operation followed by a lost response.
  • Validate generated-client interpretation where practical.

Expected behavior

HTTP status and response body communicate a consistent outcome under the API’s chosen semantics. Negative tests assert the correct error rather than treating every non-2xx response as a test failure.

Runnable examples

Each example includes a broken server, a fixed server, an OpenAPI spec, and a clrsig scenario that detects the failure.