{"record":{"id":"d9e7404615c5ab6c","repo":"Hmbown/CodeWhale","slug":"codewhale-terminal-receipt-exceeded-its-string-bound","errorCode":null,"errorMessage":"Codewhale terminal receipt exceeded its string bound","messagePattern":"Codewhale terminal receipt exceeded its string bound","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"integrations/verifiers-codewhale/codewhale_harness/harness.py","lineNumber":263,"sourceCode":"def _has_version(output: str, version: str) -> bool:\n    return (\n        re.search(\n            rf\"(?<![0-9A-Za-z.+-]){re.escape(version)}(?![0-9A-Za-z.+-])\",\n            output,\n        )\n        is not None\n    )\n\n\ndef _bounded_terminal(meta: dict[str, Any]) -> dict[str, Any]:\n    terminal: dict[str, Any] = {}\n    for key in _TERMINAL_FIELDS:\n        if key not in meta or meta[key] is None:\n            continue\n        value = meta[key]\n        if isinstance(value, str):\n            if len(value) > MAX_TERMINAL_STRING_CHARS:\n                raise RuntimeError(\"Codewhale terminal receipt exceeded its string bound\")\n        elif isinstance(value, int) and not isinstance(value, bool):\n            if value < 0 or value > 2**63 - 1:\n                raise RuntimeError(\"Codewhale terminal receipt contained an invalid count\")\n        else:\n            raise RuntimeError(\"Codewhale terminal receipt contained a non-scalar field\")\n        terminal[key] = value\n    encoded = json.dumps(terminal, sort_keys=True, separators=(\",\", \":\")).encode()\n    if len(encoded) > MAX_TERMINAL_RECEIPT_BYTES:\n        raise RuntimeError(\"Codewhale terminal receipt exceeded its total bound\")\n    return terminal\n\n\ndef _install_script(version: str) -> str:\n    version_q = shlex.quote(version)\n    install_q = shlex.quote(INSTALL_DIR)\n    release_q = shlex.quote(RELEASE_ROOT)\n    return f\"\"\"\nset -eu","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/integrations/verifiers-codewhale/codewhale_harness/harness.py#L245-L281","documentation":"Terminal receipt string fields (model, sha256 digests, posture names, etc.) are capped at MAX_TERMINAL_STRING_CHARS = 512. This RuntimeError means a string field in the metadata event's 'meta' exceeded that bound. The harness throws it to keep trace metadata bounded — an oversized string indicates a malformed or hostile receipt, so it refuses to store it.","triggerScenarios":"_bounded_terminal, called while parsing the 'metadata' event in the stream-json output, found a string field from _TERMINAL_FIELDS longer than 512 characters — e.g. a giant model identifier, padded hash, or embedded payload.","commonSituations":"Wrapping a proxy/wrapper binary that injects extra data into receipt fields; a fork or patched Codewhale writing verbose field values; JSON with multiline or corrupted output mistaken for metadata.","solutions":["Dump the raw metadata event from the program stdout to find which field is oversized","Ensure the configured binary is the genuine pinned Codewhale release, not a wrapper or shim","Check for environment variables or config that could bloat model/route identifiers","If a legitimate long field is expected, raise MAX_TERMINAL_STRING_CHARS in the harness and re-verify","Compare binary_sha256/config_sha256 output against expected values to detect tampering"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"MAX = 512\noversized = [k for k, v in meta.items()\n             if isinstance(v, str) and len(v) > MAX]\nassert not oversized, f\"oversized receipt fields: {oversized}\"","typeGuard":"def bounded(value: object) -> bool:\n    return not isinstance(value, str) or len(value) <= 512","tryCatchPattern":"try:\n    receipt = await harness.launch(ctx, trace, runtime, endpoint, secret, mcp_urls)\nexcept RuntimeError as e:\n    if \"exceeded its string bound\" in str(e):\n        logger.error(\"receipt string bound violated; check binary integrity\")\n    raise","preventionTips":["Use only the official pinned Codewhale release, not wrappers","Keep model/route identifiers short in provider config","Re-verify binary_sha256 against the release manifest","If field sizes legitimately grow, raise MAX_TERMINAL_STRING_CHARS explicitly in a reviewed change"],"tags":["validation","limits","security"],"backgroundTag":"payload-too-large","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}