flashman
← All posts

JSON null vs missing fields: debug API contract drift

Debug JSON null vs missing field bugs by comparing payloads, schemas, defaults, typed clients, rollout diffs, and safe examples during risky API rollouts.

2026-07-16 · 5 min read · Rahul Chitturi

  • json
  • api
  • debugging

A field that is missing is not always the same as a field set to null. That difference can decide whether an API keeps an existing value, clears it, applies a default, or fails validation. Contract drift often appears after a mobile app, backend worker, and public API client each interpret optional data differently.

Start by collecting one known-good payload and one failing payload from a safe environment or a carefully redacted production sample. Format both documents so reviewers can see whether the field is absent, present with null, present with an empty string, or present with an empty array.

Map field state to behavior

The bug is rarely just syntax. It is usually a mismatch between serializer behavior, schema rules, and business logic. Write down what each field state should mean before changing validation code.

  • Missing field: leave unchanged, use server default, or reject?
  • Null field: clear existing value, represent unknown, or reject?
  • Empty string or array: valid empty value or client-side placeholder?
  • Generated client: does it omit undefined fields or serialize them as null?

Make rollout changes reviewable

When fixing a contract, diff the schema, examples, generated client output, and migration notes together. If the API accepts both old and new shapes during a rollout, keep tests that show the compatibility window and the final strict contract.

For incident notes, preserve field names and value shapes while masking customer data. A synthetic payload with the same missing/null pattern is enough to explain the root cause without leaking records.

A Flashman workflow

Use the JSON formatter to inspect payload shape, the diff tool to compare failing and expected examples, and the YAML to JSON converter when OpenAPI or config examples are the source of truth.

Keep the final checklist concrete: which field state broke, which client serialized it, and which server behavior should be documented so the next integration does not repeat the mismatch.

Try these tools