{"record":{"id":"d9e7404615c5ab6c","repo":"Hmbown/CodeWhale","slug":"codewhale-terminal-receipt-exceeded-its-string-bou","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/8880682c63083a91624de936797efa3ce9e498fd/integrations/verifiers-codewhale/codewhale_harness/harness.py#L245-L281","documentation":"_bounded_terminal enforces MAX_TERMINAL_STRING_CHARS=512 on every string field of the terminal metadata (model, provider_id, route_source, the sha256 fields, error_category, ...) while parsing stdout. Longer strings raise RuntimeError and fail an otherwise successful run; the bound keeps trace metadata small and deterministic.","triggerScenarios":"A facade embedding a stack trace or long message in error_category; binary versions adding unbounded string fields to the terminal receipt; identifiers carrying long generated suffixes.","commonSituations":"Debug builds stuffing diagnostics into receipt fields; facade authors copying whole outputs into metadata; schema drift adding descriptive fields.","solutions":["Truncate terminal metadata strings to at most 512 characters in the emitter","Move long diagnostics into non-metadata events; the harness retains only scalar summaries","Keep the facade's terminal vocabulary aligned with the pinned release's field set"],"exampleFix":"# before\nmeta = {'error_category': long_stack_trace}\n# after\nmeta = {'error_category': long_stack_trace[:512]}","handlingStrategy":"validation","validationCode":"MAX = 512\nmeta = {k: (v[:MAX] if isinstance(v, str) else v) for k, v in meta.items()}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap every string written to terminal metadata at 512 chars","Keep diagnostics in event payloads, not receipt fields","Diff facade receipts against the terminal-field expectations in tests"],"tags":["receipt","bounds","parsing","harness"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}