STITCH_DRIFT
A required field was missing or incompatible, breaking the response contract.
What you will see
A call fails during validation with a drift finding that carries
level: 'error' and change: 'invalid'. The finding names the offending
path and the call surfaces a StitchError with code STITCH_DRIFT instead of
a result.
Soft drift findings — undeclared (info), coerced (warn), defaulted
(verbose) — stream as drift events but do not fail the call. Only a
hard validation failure (change: 'invalid', level: 'error') breaks the
contract.
Why it happens
Drift validates the live response against the declared output schema (the
consumer contract). A required field was missing or the value was
incompatible with its declared type — the schema could not produce a valid
result. Because the field is required, this is a hard contract break: the engine
throws rather than returning a value that does not match the declared TypeScript
type.
Soft drift (undeclared, coerced, defaulted) is always non-fatal. Fatality
lives entirely in the schema: a required field whose absence or type mismatch
throws; an optional field whose absence is silently tolerated.
How to fix
Read the finding's path to see exactly what moved, then decide which case you
are in:
- The change is intended. The upstream shape genuinely changed and you want
the new shape. Update the
outputschema to match the new type or mark the field optional, and the error stops. - It is a vendor regression. You did not expect this change — that is the signal drift exists to give you. Treat the thrown error as the alert and act on the upstream break.
If a field should be tolerated when absent, declare it .optional() in the
schema. Validation will then succeed, and drift may emit a soft defaulted
finding if the schema has a .default() — but the call will not throw.
import { , } from 'stitchapi';
import { } from 'zod';
const = ({
: 'https://api.example.com',
: '/user',
: (
.({
// `id` is required — its absence or type mismatch throws STITCH_DRIFT.
: .(),
// `displayName` is optional — its absence is tolerated, no error thrown.
: .().(),
}),
),
});See the drift guide for how the schema's
required/optional structure maps to finding levels, and how severity and
ignore filter soft findings.
Stuck, or debugging with an agent? Ask the docs
MCP — search_docs('STITCH_DRIFT') pulls
this page and the related guides straight into context.