Problem · target: negative test cases for rest api

Negative Tests for User profiles API: What to Assert

User needs a catalogue of negative cases for a REST API without inventing them by hand.

Direct answer

Invalid payloads slip through because the schema is only used to validate requests, never to produce the negative cases, and User profiles API has 7 constraints that nobody is testing.

This covers contract violations rather than memory-safety bugs, so a fuzzer is still the right tool when the defect class is a parser crash.

The engine rejected the violating row for User profiles API with "CHECK constraint failed: length(trim(bio)) > 0", which is the error the API should return to the client instead of a success response.

Data as of 2026-11-18 · source: 11 Stack Overflow questions, 4 Hacker News stories, @octokit/request at 208,281,564 monthly downloads · negative-case messages reproduced by executing the fixture against a local SQL engine (Node.js v24.22.0, engine 3.53.4) at 2026-11-18T11:53:54.233Z

What actually goes wrong — User profiles

The failure is rarely a crash. The API accepts the payload, returns 200, and stores a row that violates a rule the schema promised to enforce. For User profiles API, the reference engine rejected the bad row with "NOT NULL constraint failed: users.email" — that is the message the API should have surfaced to the client instead of a success response.

The four failure modes

Invalid payloads cluster into four families, and the User profiles API fixture exercises all of them. Missing required fields, wrong types, out-of-range values and values outside a declared enum. Each family maps to a distinct engine error, and each family needs a distinct assertion in the test suite.

What the boundary probes look like

For User profiles API, the range probe on users.bio sits one step outside the boundary. The constraint is char_length(btrim("bio")) > 0 and the probe value is . The engine said "CHECK constraint failed: length(trim(bio)) > 0". A test that asserts a 4xx response for this value is asserting that the constraint the schema declares is actually enforced at the edge.

The assertion you actually want

Assert on the response code and on the error body, not on the absence of a crash. For the User profiles API fixture, the assertion that catches a regression is a request carrying bio= , expecting a 4xx status and an error body that names the field. A test that only asserts "the request failed" passes even when the API fails for the wrong reason.

Where a fuzzing tool is the wrong answer

Unstructured fuzzing finds crashes, which is a different job from finding contract violations. For User profiles API, a schema-derived negative set covers the cases a fuzzer would take hours to stumble into, and each one has a deterministic expected response. Reach for a fuzzer when the bug class is a parser crash, not when the bug class is a contract the API forgot to enforce.

Real constraint failures for the User profiles API fixtureReproduced by executing the fixture against a local SQL engine (Node.js v24.22.0, engine 3.53.4) on 2026-11-18T11:53:54.233Z. The message column is verbatim engine output; the SQLSTATE column is the PostgreSQL error class for the same constraint class.
Failure classColumnSQLSTATEError nameEngine message (verbatim)
Missing required fieldusers.email23502not_null_violationNOT NULL constraint failed: users.email
Out-of-contract valueusers.bio23514check_violationCHECK constraint failed: length(trim(bio)) > 0
Boundary probes for every constrained column in User profiles APIOne violating value per constraint, with the boundary it crosses.
TableColumnDeclared ruleProbe valueWhy it is invalid
usersbionot blank" "blank after trimming
userslocale2 to 5 charactersetoo short
users.ts

npx --yes @wenlu8848/schemaseed generate --input ./prob_profiles.openapi.yaml --out ./seed --formats ts --count 10 --seed 42

Download prob_profiles.openapi.yaml

// Generated by schemaseed — do not edit by hand.
// Table: users

export interface UsersRow {
  id: string;
  email: string;
  display_name: string;
  bio?: string | null;
  avatar_url?: string | null;
  locale: string;
  created_at: string;
}

export const usersRows: UsersRow[] = [
    {
      "id": "6aa597ce-583e-471b-b4f9-6a12fc245d48",
      "email": "hana.ibarra381@example.net",
      "display_name": "Quinn Novak",
      "bio": "dqhYk",
      "avatar_url": "https://mail.example/willow/758",
      "locale": "Nairo",
      "created_at": "2024-05-21T04:48:14.000Z"
    },
    {
      "id": "498bd819-019c-4335-afb7-45cd91b14ebb",
      "email": "sami.lund277@example.org",
      "display_name": "Nairobi, Elm Avenue 92",
      "avatar_url": "https://test.dev/willow/124",
      "locale": "umbra",
      "created_at": "2022-07-11T21:38:30.000Z"
    },
    {
      "id": "7b07e38c-f830-4b22-8b49-7295bd469c8e",
      "email": "chen.adler418@test.dev",
      "display_name": "alpha cedar",
      "avatar_url": "https://mail.example/harbor/304",
      "locale": "zephy",
      "created_at": "2020-02-03T00:02:50.000Z"
    },
    {
      "id": "a93b1c4c-e67e-4b8c-9f51-16d23e2401a7",
      "email": "rosa.novak512@example.net",
      "display_name": "onyx indigo",
      "bio": null,
      "avatar_url": "https://example.org/fable/547",
      "locale": "Fay C",
      "created_at": "2026-03-09T01:56:35.000Z"
    },
    {
      "id": "85ef2671-d17f-4404-95d7-319d28c2832c",
      "email": "chen.novak151@test.dev",
      "display_name": "Quinn Bianchi",
      "bio": "Zy",
      "avatar_url": "https://example.com/summit/197",
      "locale": "meado",
      "created_at": "2026-12-12T07:23:40.000Z"
    },
    {
      "id": "31bda2d2-cb16-4e7d-b88a-00bbb030ed8a",
      "email": "jun.bianchi336@example.net",
      "display_name": "umbra juniper",
      "avatar_url": "https://example.org/harbor/871",
      "locale": "lumen",
      "created_at": "2024-09-22T11:09:17.000Z"
    },
    {
      "id": "52ddf724-aa7f-4aaf-8a11-2909d74ddc49",
      "email": "hana.duarte555@example.com",
      "display_name": "Sami Novak",
      "bio": "9tumXdi7h",
      "avatar_url": "https://example.net/umbra/657",
      "locale": "fay.d",
      "created_at": "2020-02-03T20:58:48.000Z"
    },
    {
      "id": "fccfe1ae-7838-4d53-a84f-9708e1c1f3ed",
      "email": "eli.adler556@test.dev",
      "display_name": "Toronto, Riverside Lane 197",
      "bio": "x5geapp",
      "avatar_url": "https://test.dev/river/392",
      "locale": "grove",
      "created_at": "2020-03-16T06:23:45.000Z"
    },
    {
      "id": "e61bfd52-0449-4a80-a564-d0cfadcfa0eb",
      "email": "quinn.costa686@mail.example",
      "display_name": "Auckland, Harbor Road 210",
      "avatar_url": "https://example.com/kelp/945",
      "locale": "Ada K",
      "created_at": "2021-02-27T22:12:32.000Z"
    },
    {
      "id": "eda9b425-d04b-43da-ab49-850d43f16f11",
      "email": "omar.novak260@example.org",
      "display_name": "gus.jansen@example.net",
      "bio": "tuzYzved1",
      "avatar_url": "https://mail.example/zephyr/3",
      "locale": "sami.",
      "created_at": "2021-04-12T09:31:58.000Z"
    }
  ];

Frequently asked questions

How many invalid cases do I actually need?
One per constraint class, not one per field. The User profiles API fixture declares its rules across 1 tables and 7 columns, and the table above lists the probe value for each.
Should I fuzz instead?
Only for crashes. A schema-derived negative set covers every declaration in User profiles API deterministically, with an expected response for each.
What status code should the API return?
Your API decides that, consistently. The generator hands you the violating value and the constraint it breaks — users.bio on this fixture — so the assertion can name the field.
Do I need to write the assertions by hand?
No. The negative instances come from the schema. For User profiles API the first probe is users.bio = , and the engine replied "CHECK constraint failed: length(trim(bio)) > 0".

Run it against your own schema

SchemaSeed is MIT licensed and free: unlimited local generation, no account, no telemetry and no usage limit. It reads your schema file on your own machine, so nothing is uploaded anywhere. If it saves you time, you can support the project.

Get SchemaSeed — free Support the project

Questions: support@schemaseed.drz8848.win