Schema-Guided JSON Repair
schema.repair_json_to_schema
Overview
You send a document that already parses, the schema it violates, and the exact list of repairs we may perform. We apply only those, revalidate, and return the repaired document together with the RFC 6902 patch that produced it, so every edit to your data can be reviewed, replayed or rejected. Where a violation admits two authorised repairs we apply neither and name both: guessing between them would be invention wearing a repair's name. schema.repair_json fixes what stops a document parsing; this skill starts where that one stops.
Agents and hand-written fixtures produce documents that are one string quote away from valid. Fixing those by hand is tedious; fixing them with an unbounded coercion library is how a "0" becomes false and a bug ships. An allowlist the caller writes, plus a patch the caller can read, is the only version of this that is safe to run over someone else's data.
Reliability
The same document, schema and policy always produce the same patch, independent of your machine's locale, time zone and default character set — enum case folding is Locale.ROOT and numeric coercion accepts only JSON's own grammar, so a decimal comma is never a number here. Applying the patch to your own copy of the original reproduces json exactly. Fifteen refusals stop the call. REPAIR_SCHEMA_TEXT_INVALID means the document does not parse and carries the json_repair recovery intent, so schema.repair_json can make a retry meaningful; REPAIR_SCHEMA_TEXT_TOO_LARGE and REPAIR_SCHEMA_SCHEMA_TOO_LARGE mean a side is over 262144 bytes; REPAIR_SCHEMA_SCHEMA_INVALID means the schema is absent, not an object, or unusable; REPAIR_SCHEMA_DRAFT_UNSUPPORTED means draft is not one of the three published members; REPAIR_SCHEMA_POLICY_INVALID means allow is empty, over eight members, or names a repair we do not publish, or a policy number is out of range; REPAIR_SCHEMA_POLICY_UNAUTHORISED means applyDefaults is true without APPLY_SCHEMA_DEFAULT in allow, which is a contradiction we will not resolve for you; REPAIR_SCHEMA_LIMIT_EXCEEDED means the document needs more repairs than maxRepairs, or has more violations than one call examines; REPAIR_SCHEMA_NODE_LIMIT_EXCEEDED means the document is over 50000 nodes, the schema over 20000, or either nests deeper than 50 levels — the platform parser's ceiling, which binds before the 64-level structural limit because the document arrives as text; REPAIR_SCHEMA_REGRESSION means a repair introduced a violation that was not there before, so the whole patch is refused rather than handing back a document worse than the one you sent; REPAIR_SCHEMA_REF_REMOTE_REFUSED, REPAIR_SCHEMA_REF_CYCLE_DETECTED and REPAIR_SCHEMA_REF_DEPTH_EXCEEDED are the reference refusals; REPAIR_SCHEMA_WORK_REFUSED means the run was projected past the 2000000-unit budget before it started and reports both numbers; and REPAIR_SCHEMA_OUTPUT_TOO_LARGE means the repaired document, the patch and the evidence would not fit the 2 MiB response ceiling, so lower maxRepairs.
Context footprint
Your document comes back to you, which is the point of the call and the reason this is the one skill in the pack that carries caller content: a patch is unusable without the pointers it applies to. Everything beside json and patch is metadata — pointers, keywords and repair names — and no error message repeats a value. A successful call costs 2 execution credits.
When to use it
When a payload fails validation on mechanical grounds and you want the fix and the audit trail in one call.
When the document does not parse, when the missing piece is real business data, or when you want the violations themselves rather than a repair.
Scope
Non-goals
- We never invent a business value; the one exception is a schema-declared default you explicitly authorise
- We never choose between two authorised repairs — both are named and neither runs
- We never fix a document that does not parse; schema.repair_json does that
- We never truncate meaning: only leading or trailing whitespace is ever cut
- We never report a repair we did not revalidate
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content and may return submitted, transformed, extracted, or reformatted content.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response may contain submitted or transformed content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Candidate document as JSON text that already parses, 1 through 262144 bytes. |
| schema | object | Yes | Inline JSON Schema the document should satisfy, 2 through 262144 bytes; extra keys are schema keywords. — unconstrained RFC 8259 JSON items. |
| draft | string | No | Dialect to revalidate under; omit it for DRAFT_2020_12. |
| repairPolicy | object | Yes | Closed authorised-repair policy with a required allow list plus optional maxRepairs, applyDefaults and onAmbiguous. |
| formatValidation | boolean | No | Whether format assertions participate in revalidation; omit it for false. |
| maxErrors | integer | No | How many post-repair errors to list, 1 through 500; omit it for 100. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| valid | boolean | Yes | Whether the document satisfies the schema after the repairs. |
| json | object | Yes | Repaired document as JSON, ready to forward without applying the patch locally. |
| patch | array | Yes | Replayable RFC 6902 operations, 0 through 500 closed objects; empty when nothing changed. |
| repairs | array | Yes | Applied repairs, 0 through 500 closed objects with pointer, repair name, keyword, schemaPointer and optional types. |
| unresolved | array | Yes | Violations left alone, 0 through 500 closed objects with pointer, keyword, schemaPointer, reason and candidates. |
| errors | array | Yes | Problems in validator order, 0 through 500 closed {path, schemaPath, keyword, message} objects; empty when valid. |
| summary | object | Yes | Closed counts with violationCount, repairCount, unresolvedCount, validationPasses, the draft URL, whether anything changed and whether lists were truncated. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"schema.repair_json_to_schema","input":{"text":"{\"count\":\"17\"}","schema":{"type":"object","properties":{"count":{"type":"integer"}}},"repairPolicy":{"allow":["COERCE_STRING_TO_INTEGER"]}}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("schema.repair_json_to_schema", {"text":"{\"count\":\"17\"}","schema":{"type":"object","properties":{"count":{"type":"integer"}}},"repairPolicy":{"allow":["COERCE_STRING_TO_INTEGER"]}});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| REPAIR_SCHEMA_TEXT_INVALID | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_TEXT_TOO_LARGE | 429 | No | A size, quota, rate, or time limit was exceeded. |
| REPAIR_SCHEMA_SCHEMA_INVALID | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_SCHEMA_TOO_LARGE | 429 | No | A size, quota, rate, or time limit was exceeded. |
| REPAIR_SCHEMA_DRAFT_UNSUPPORTED | 400 | No | The skill does not support the requested variant. |
| REPAIR_SCHEMA_POLICY_INVALID | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_POLICY_UNAUTHORISED | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| REPAIR_SCHEMA_NODE_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| REPAIR_SCHEMA_REGRESSION | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_REF_REMOTE_REFUSED | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_REF_CYCLE_DETECTED | 400 | No | The request payload failed this skill's input validation. |
| REPAIR_SCHEMA_REF_DEPTH_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| REPAIR_SCHEMA_WORK_REFUSED | 429 | No | A size, quota, rate, or time limit was exceeded. |
| REPAIR_SCHEMA_OUTPUT_TOO_LARGE | 429 | No | A size, quota, rate, or time limit was exceeded. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- We never invent a business value; the one exception is a schema-declared default you explicitly authorise
- We never choose between two authorised repairs — both are named and neither runs
- We never fix a document that does not parse; schema.repair_json does that
- We never truncate meaning: only leading or trailing whitespace is ever cut
- We never report a repair we did not revalidate
- Fixing JSON that does not parse, which schema.repair_json does
- Filling in missing business data, which nothing here will do
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "schema.repair_json_to_schema",
"input": {
"text": "{\"count\":\"17\"}",
"schema": {
"type": "object",
"properties": {
"count": {
"type": "integer"
}
}
},
"repairPolicy": {
"allow": [
"COERCE_STRING_TO_INTEGER"
]
}
}
}Examples
A stringified integer coerced and revalidated
{
"text": "{\"count\":\"17\"}",
"schema": {
"type": "object",
"properties": {
"count": {
"type": "integer"
}
}
},
"repairPolicy": {
"allow": [
"COERCE_STRING_TO_INTEGER"
]
}
}{
"repairs": [
{
"pointer": "/count",
"repair": "COERCE_STRING_TO_INTEGER",
"keyword": "type",
"schemaPointer": "/properties/count/type",
"fromType": "string",
"toType": "integer"
}
],
"unresolved": [],
"valid": true,
"json": {
"count": 17
},
"summary": {
"violationCount": 1,
"repairCount": 1,
"unresolvedCount": 0,
"validationPasses": 2,
"draft": "https://json-schema.org/draft/2020-12/schema",
"changed": true,
"truncated": false
},
"errors": [],
"patch": [
{
"op": "replace",
"path": "/count",
"value": 17
}
]
}A document that already satisfies its schema
{
"text": "{\"count\":17}",
"schema": {
"type": "object",
"properties": {
"count": {
"type": "integer"
}
}
},
"repairPolicy": {
"allow": [
"COERCE_STRING_TO_INTEGER"
]
}
}{
"repairs": [],
"unresolved": [],
"valid": true,
"json": {
"count": 17
},
"summary": {
"violationCount": 0,
"repairCount": 0,
"unresolvedCount": 0,
"validationPasses": 1,
"draft": "https://json-schema.org/draft/2020-12/schema",
"changed": false,
"truncated": false
},
"errors": [],
"patch": []
}Recommended use cases
- Coerce an agent's stringified numbers and booleans into a typed payload
- Bring a hand-written fixture up to its schema with an auditable patch
- Decide whether a rejected payload is mechanically fixable at all
Avoid for
- Fixing JSON that does not parse, which schema.repair_json does
- Filling in missing business data, which nothing here will do
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.