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 PDFs to Product Data: Where AI Needs a Second Check
From Supplier PDFs to Product Data: Where AI Needs a Second Check
2026-09-07

Supplier files need more than extraction. Here’s how to check coverage, match SKUs, resolve unclear units and prices, and test product data before a catalogue import.

Illustrated infographic summarizing: Shorter TLS Certificates: Will Your Renewal Setup Keep Up?
Shorter TLS Certificates: Will Your Renewal Setup Keep Up?
2026-09-06

Shorter TLS certificates leave less room for renewal problems. Check domain validation, scheduling, deployment and the certificate your customers actually receive.

Illustrated infographic summarizing: Your AI Image Has Content Credentials. Will Your Website Keep Them?
Your AI Image Has Content Credentials. Will Your Website Keep Them?
2026-09-05

AI image credentials can disappear during routine website processing. Learn how to test your CMS, optimizer, CDN, and publishing workflow end to end.

Illustrated infographic summarizing: What Are Customers Asking? Let AI Find the Patterns in Support Tickets
What Are Customers Asking? Let AI Find the Patterns in Support Tickets
2026-09-04

AI-based ticket analysis can uncover recurring complaints, product defects and gaps in documentation—without the company needing yet another chatbot.

Illustrated infographic summarizing: OpenAI Has Machine Identity Now. Which Jobs Should Lose API Keys?
OpenAI Has Machine Identity Now. Which Jobs Should Lose API Keys?
2026-09-03

OpenAI’s X.509 workload identity can replace API keys for the right workloads. This practical framework helps teams decide where to start safely.

Illustrated infographic summarizing: WordPress 7.1 Exposes AI-Ready Actions. Who Gets to Run Them?
WordPress 7.1 Exposes AI-Ready Actions. Who Gets to Run Them?
2026-09-02

WordPress 7.1 helps AI agents discover and invoke site abilities. Here is how to keep exposure, authentication and permission firmly separate.

Illustrated infographic summarizing: From Sales Meeting to CRM: Automate Follow-Up Without Compromising Data Quality
From Sales Meeting to CRM: Automate Follow-Up Without Compromising Data Quality
2026-09-01

How to use AI for meeting notes and follow-up while fixed rules protect CRM data, customer matching and the sales pipeline from errors and premature changes.

Illustrated infographic summarizing: Your AI Gateway Can Name the User. Decide What That Log Is For
Your AI Gateway Can Name the User. Decide What That Log Is For
2026-08-31

Identity-aware AI Gateway logs can sharpen security and cost control, but only when attribution, access, retention, guardrails, and response are clearly defined.

Illustrated infographic summarizing: Zero Data Retention Is a Workflow Audit, Not a Checkbox
Zero Data Retention Is a Workflow Audit, Not a Checkbox
2026-08-30

Zero Data Retention covers the provider, not every copy in your stack. See how to audit endpoints, logs, storage, deletion and project-level controls.

Illustrated infographic summarizing: MCP 2026-07-28 Is an Auth Migration, Not a Version Bump
MCP 2026-07-28 Is an Auth Migration, Not a Version Bump
2026-08-29

MCP’s July 2026 release removes protocol sessions and tightens OAuth. Here’s a practical plan for migrating clients, servers and enterprise access safely.

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