Skip to main content
Home
GrN.dk

Main navigation

  • Articles
  • Cases
  • Services
  • Your Digital Project Manager
  • About Greg Nowak
  • Image Gallery
  • Contact
User account menu
  • Log in

Join my community / free newsletter — sign up here

Breadcrumb

  1. Home

When AI writes JSON, one bad field can break the workflow

Illustrated infographic summarizing: When AI writes JSON, one bad field can break the workflow

By Greg Nowak. Updated 15 August 2026.

AI-generated JSON looks reassuringly precise. It has field names, tidy nesting, and none of the ambiguity of a paragraph. That makes it useful for updating CRM records, creating support tickets, preparing product data, routing leads, or drafting CMS entries.

It also makes mistakes easier to automate.

A payload can be valid JSON and still assign a lead to the wrong account, send an unsupported status to a billing system, or schedule an action for the wrong date. The operational question is therefore not simply, “Can the model return JSON?” It is, “What must happen before our software trusts it?”

Structured output is a contract, not an approval

Current AI platforms can constrain model output to a defined structure, and JSON Schema provides a standard vocabulary for describing that structure. This is a substantial improvement over asking for JSON in a prompt and hoping that the response parses.

Use the schema to define the expected object, required properties, data types, array contents, and accepted values. Reject unexpected fields where appropriate. Declare the JSON Schema dialect your tooling supports rather than leaving validators to make assumptions.

But schema compliance answers only a structural question. It does not establish that a customer ID exists, an amount is commercially plausible, a user is authorised to perform an action, or a proposed change is safe to execute. Those decisions remain in your application.

Gate What it catches Failure response
Parse Truncated or malformed JSON Reject or retry once
Schema Missing fields, wrong types, extra properties, invalid enums Return precise validation errors
Business rules Unknown IDs, impossible dates, duplicate records, unsafe amounts Stop or send for review
Permission Actions the user, workflow, or model may not perform Deny and log
Execution Duplicate writes and downstream API failures Use idempotency, rollback where possible, and alerting
A practical sequence for handling AI-generated JSON before it changes a production system.

Design the schema around the receiving system

Start with the API or database that will receive the data, not with the answer the model finds easiest to produce. If a support platform accepts only low, normal, and urgent, define that enum. If a publishing workflow needs an ISO-formatted date, require the format your application expects and parse it explicitly. If an amount is monetary, define how currency, precision, and tax treatment are represented.

Be deliberate about optional values. “Missing,” null, and an empty string may trigger different downstream behaviour. Document which one is allowed and what it means. Avoid making every property optional merely to increase the model’s success rate; that transfers uncertainty into operations.

Also decide whether extra fields are allowed. Preventing undeclared properties can catch misspelled keys and stop the model from quietly inventing data your application never requested. Check the schema subset supported by your chosen model provider, because constrained-output implementations do not necessarily support every JSON Schema feature.

Valid JSON can still be commercially wrong

After structural validation, apply rules grounded in your own data and processes. Confirm that identifiers resolve to the right tenant or customer. Check that dates fall within an acceptable window. Verify that a proposed state transition is allowed—for example, that an invoice cannot move directly from “draft” to “refunded.”

Separate descriptive fields from decision fields. A generated summary can usually tolerate variation. A price, account ID, payment status, permission level, or destination email needs much tighter control. For sensitive actions, let the model propose the value while deterministic code retrieves or confirms it.

Cross-field checks matter too. Each field may be valid on its own while the combination is not: a delivery date can precede an order date, a currency may not match the account, or a “closed” ticket may have no resolution.

Keep tool execution under application control

Tool calling does not mean the model should receive unrestricted access to business systems. The model proposes a tool name and arguments; the application decides whether and how to execute them.

Maintain an allowlist of tools for each workflow. Validate arguments even when the provider says the output follows a schema. Apply the user’s real permissions, not a generic service account’s maximum access. Require confirmation for consequential actions such as sending messages, publishing content, changing financial records, or deleting data.

Give read operations and write operations different risk levels. “Look up this customer” and “change this customer’s billing address” should not pass through the same approval path. Where an API supports it, use idempotency keys so a timeout or retry does not create the same ticket, payment, or record twice.

Make failure an ordinary, visible state

A retry is useful when output is malformed or misses a constraint. Return the exact validation errors to the model and request a corrected object. Set a small retry limit, however. Repeating the same request indefinitely increases cost and latency while hiding a design problem.

Classify failures before retrying. A malformed date may be repairable. An unknown customer ID requires fresh data or human input. A denied permission must not be “fixed” by asking the model again.

Log enough to diagnose the workflow: model and version, schema version, correlation ID, validation outcome, retry count, tool requested, execution result, and timing. Avoid placing secrets or unnecessary personal data in logs. Monitor failure rates by field; repeated errors often reveal ambiguous instructions, schema drift, or a changed downstream API.

A practical production checklist

  • Version the schema alongside the code that consumes it.
  • Test valid payloads, missing fields, wrong types, extra fields, boundary values, and hostile input.
  • Run structural and business-rule validation before every write.
  • Use least-privilege credentials and action-specific approval rules.
  • Cap retries and create a human-review route for unresolved cases.
  • Make writes idempotent where the receiving system permits it.
  • Alert on recurring validation and execution failures.

For a proof of concept, getting a neat JSON object may feel like success. In production, it is only the first checkpoint. A dependable integration treats model output as untrusted input, makes every consequential action explicit, and leaves an audit trail when something goes wrong.

Need to harden an AI workflow?

If your prototype is about to touch a CRM, CMS, support platform, or finance process, Greg can help map the handoffs, define schemas and controls, and build a failure path your team can operate. Start with a practical conversation about the workflow.

Related on GrN.dk

  • A Voice Agent Is Only Ready When the Human Handoff Works
  • Structured Outputs Make Intake Automation a Schema Design Job
  • Agent-ready APIs need a contract audit before MCP rollout

Need help with this kind of work?

Discuss your AI workflow with Greg Get in touch with Greg.

Sources

  • Structured model outputs — OpenAI API
  • Understanding JSON Schema: Objects
  • Tool use with Claude — Claude Platform Docs
  • JSON Schema — Pydantic Validation
Last modified
2026-08-15

Tags

  • AI integrations
  • structured outputs
  • JSON Schema
  • api automation
  • workflow validation

Review Greg on Google

Greg Nowak Google Reviews

 

Written recommendations from Trafik og Veje, Aarhus Municipality (2011) and AgroTech (2010) — read them on LinkedIn.

Illustrated infographic summarizing: From Supplier Invoice to Bookkeeping: AI with a Control Checkpoint
From Supplier Invoice to Bookkeeping: AI with a Control Checkpoint
2026-08-18

AI can reduce the work involved in processing supplier invoices, but reliable bookkeeping requires validation, duplicate checks, approval and a clear audit trail.

Illustrated infographic summarizing: Nginx 1.30 Changed the Upstream Defaults—Test Before You Upgrade
Nginx 1.30 Changed the Upstream Defaults—Test Before You Upgrade
2026-08-17

Nginx 1.30 defaults upstream proxying to HTTP/1.1 with keepalive enabled. Here is what to inspect, model and test before upgrading.

Illustrated infographic summarizing: OpenAI’s Assistants API Shuts Down in Ten Days. Is Your App Ready?
OpenAI’s Assistants API Shuts Down in Ten Days. Is Your App Ready?
2026-08-16

OpenAI’s Assistants API shuts down on August 26, 2026. Learn what to inventory, how to preserve state and how to cut over without breaking the product.

Illustrated infographic summarizing: WordPress 7.1 Forces the Editor Into an iframe—Test Your Custom Blocks
WordPress 7.1 Forces the Editor Into an iframe—Test Your Custom Blocks
2026-08-15

WordPress 7.1 removes the non-iframe editor fallback. Learn how to audit custom blocks, test real workflows and fix compatibility issues before launch.

Illustrated infographic summarizing: GitHub will stop sending jobs to stale self-hosted runners
GitHub will stop sending jobs to stale self-hosted runners
2026-08-14

GitHub starts enforcing runner versions on August 24, 2026. Audit and upgrade self-hosted runners before builds and deployments start stalling.

Illustrated infographic summarizing: Your AI Agent Has Shell Access. What Can It Reach?
Your AI Agent Has Shell Access. What Can It Reach?
2026-08-13

A practical guide to mapping what a shell-enabled AI agent can reach, then containing its access to files, credentials, networks, tools, and high-impact actions.

Illustrated infographic summarizing: Cloudflare Changed DoH JSON. What Else Is Parsing DNS as Text?
Cloudflare Changed DoH JSON. What Else Is Parsing DNS as Text?
2026-08-12

Cloudflare’s DoH JSON change exposes brittle DNS parsing. Find affected scripts, test both formats, and choose a safer integration contract.

Illustrated infographic summarizing: Your Website Can Answer Questions Now. Should It?
Your Website Can Answer Questions Now. Should It?
2026-08-11

NLWeb makes conversational website search practical to deploy. The real question is whether your content, users and team are ready to support it.

Illustrated infographic summarizing: AI Search Finally Has Reports. Now Connect Visibility to Revenue
AI Search Finally Has Reports. Now Connect Visibility to Revenue
2026-08-11

Google and Bing now expose first-party AI search data. The real task is connecting citations and impressions to analytics, CRM outcomes, and revenue.

Illustrated infographic summarizing: The Bot Passed Your CAPTCHA. What Did It Do Next?
The Bot Passed Your CAPTCHA. What Did It Do Next?
2026-08-11

Passing a challenge is only one signal. Session analysis, server-side validation and endpoint-specific controls help reduce bot abuse without blocking customers.

More articles

Built by AI — available for your business. The daily articles on this site are researched, written and illustrated by an autonomous AI pipeline. At nowa.dk I install the same kind of AI automation in businesses at fixed prices — site in Danish, English version here, and web/marketing agencies have a dedicated page.

RSS feed

Footer

  • All articles
  • Contact

GrN.dk — AI automation, web platforms, web optimization, data handling and logistics.

© 2026 GrN.dk · LinkedIn · Contact · AI automation in Danish: nowa.dk

Behind GrN.dk: Individual Entrepreneur Codecrafter · Tax ID 305669096 · Bakhtrioni St. 22, 0194 Tbilisi, Georgia · official business register