Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Schema-Guided JSON Repair

schema.repair_json_to_schema

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

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

Note
We apply the repairs you authorise to a document that parses but violates its schema, revalidate, and return the document with the patch that made it.

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

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

data-transformationvalidation

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call2 credits

File handling

Accepts file_refProduces file_refMax input1 MB

How we handle your data

Sensitive output possible
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
textstringYesCandidate document as JSON text that already parses, 1 through 262144 bytes.
schemaobjectYesInline JSON Schema the document should satisfy, 2 through 262144 bytes; extra keys are schema keywords. — unconstrained RFC 8259 JSON items.
draftstringNoDialect to revalidate under; omit it for DRAFT_2020_12.
repairPolicyobjectYesClosed authorised-repair policy with a required allow list plus optional maxRepairs, applyDefaults and onAmbiguous.
formatValidationbooleanNoWhether format assertions participate in revalidation; omit it for false.
maxErrorsintegerNoHow many post-repair errors to list, 1 through 500; omit it for 100.

Output schema

FieldTypeRequiredDescription
validbooleanYesWhether the document satisfies the schema after the repairs.
jsonobjectYesRepaired document as JSON, ready to forward without applying the patch locally.
patcharrayYesReplayable RFC 6902 operations, 0 through 500 closed objects; empty when nothing changed.
repairsarrayYesApplied repairs, 0 through 500 closed objects with pointer, repair name, keyword, schemaPointer and optional types.
unresolvedarrayYesViolations left alone, 0 through 500 closed objects with pointer, keyword, schemaPointer, reason and candidates.
errorsarrayYesProblems in validator order, 0 through 500 closed {path, schemaPath, keyword, message} objects; empty when valid.
summaryobjectYesClosed counts with violationCount, repairCount, unresolvedCount, validationPasses, the draft URL, whether anything changed and whether lists were truncated.

API contract

POST /v1/execute
curl
curl -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"]}}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
REPAIR_SCHEMA_TEXT_INVALID400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_TEXT_TOO_LARGE429NoA size, quota, rate, or time limit was exceeded.
REPAIR_SCHEMA_SCHEMA_INVALID400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_SCHEMA_TOO_LARGE429NoA size, quota, rate, or time limit was exceeded.
REPAIR_SCHEMA_DRAFT_UNSUPPORTED400NoThe skill does not support the requested variant.
REPAIR_SCHEMA_POLICY_INVALID400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_POLICY_UNAUTHORISED400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
REPAIR_SCHEMA_NODE_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
REPAIR_SCHEMA_REGRESSION400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_REF_REMOTE_REFUSED400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_REF_CYCLE_DETECTED400NoThe request payload failed this skill's input validation.
REPAIR_SCHEMA_REF_DEPTH_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.
REPAIR_SCHEMA_WORK_REFUSED429NoA size, quota, rate, or time limit was exceeded.
REPAIR_SCHEMA_OUTPUT_TOO_LARGE429NoA size, quota, rate, or time limit was exceeded.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "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

Inputjson
{
  "text": "{\"count\":\"17\"}",
  "schema": {
    "type": "object",
    "properties": {
      "count": {
        "type": "integer"
      }
    }
  },
  "repairPolicy": {
    "allow": [
      "COERCE_STRING_TO_INTEGER"
    ]
  }
}
Expected outputjson
{
  "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

Inputjson
{
  "text": "{\"count\":17}",
  "schema": {
    "type": "object",
    "properties": {
      "count": {
        "type": "integer"
      }
    }
  },
  "repairPolicy": {
    "allow": [
      "COERCE_STRING_TO_INTEGER"
    ]
  }
}
Expected outputjson
{
  "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": []
}
  • 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

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.

Tags

jsonschemavalidationtransformation