Skip to content
← All rules
API ContractsHTTP contracts

api-contracts/no-misleading-http-status

Explicit HTTP status exits should agree with the route's visible result while allowing accepted work and deliberate protocol or privacy contracts.

httpstatus-codesroutes
TypeScript
app.post("/users", async (_req, res) => { await createUser(); res.sendStatus(404); });
Finding

Disallow statuses that contradict visible outcomes.

Setup

Install the package, register its plugin factory, then enable the rule.

Install the package

pnpm add -D @scruple/api-contracts

Register the plugin

In scruple.config.ts, register the factory under the api-contracts namespace used by the rule ID.

import { apiContracts } from "@scruple/api-contracts";

plugins: {
  "api-contracts": apiContracts(),
},

Enable the rule

"api-contracts/no-misleading-http-status": "warn"
Package
@scruple/api-contracts
Default threshold
0.9
Minimum confidence
0.75

Released under the MIT License.