{"record":{"id":"7107cb922d13daec","repo":"paperclipai/paperclip","slug":"createos-process-output-is-invalid","errorCode":null,"errorMessage":"CreateOS process output is invalid.","messagePattern":"CreateOS process output is invalid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/createos/src/execute.ts","lineNumber":160,"sourceCode":"          throw new Error(\"CreateOS process output was evicted before it could be read.\");\n        }\n        if (signal.aborted || (error instanceof CreateosApiError && error.status < 500 && error.status !== 429)) throw error;\n        if (++reconnects > 3) throw new Error(\"CreateOS process output connection failed.\");\n        await delay(250, undefined, { signal });\n        continue;\n      }\n      try {\n        for await (const event of events(response)) {\n          if (event.type === \"heartbeat\") continue;\n          if (event.type === \"data\") {\n            const seq = event.seq;\n            if (typeof seq !== \"number\" || !Number.isSafeInteger(seq) || seq < 1) throw new Error(\"CreateOS process sequence is invalid.\");\n            if (seq <= cursor) continue;\n            if (seq !== cursor + 1) throw new Error(\"CreateOS process output has a sequence gap.\");\n            if ((event.stream !== \"stdout\" && event.stream !== \"stderr\") ||\n                typeof event.data_base64 !== \"string\" ||\n                !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(event.data_base64)) {\n              throw new Error(\"CreateOS process output is invalid.\");\n            }\n            output.write(event.stream, Buffer.from(event.data_base64, \"base64\"));\n            cursor = seq;\n          } else if (event.type === \"exit\") {\n            const exitCode = event.exit_code;\n            const exitSignal = event.signal;\n            if (!(typeof exitCode === \"number\" && Number.isInteger(exitCode)) &&\n                !(typeof exitSignal === \"string\" && /^SIG[A-Z0-9]+$/.test(exitSignal))) {\n              throw new Error(\"CreateOS process exit status is missing.\");\n            }\n            completed = true;\n            output.finish();\n            return {\n              exitCode: typeof exitCode === \"number\" ? exitCode : null,\n              signal: typeof exitSignal === \"string\" ? exitSignal : null,\n              timedOut: false, stdout: output.stdout, stderr: output.stderr,\n              metadata: { processId, outputTruncated: output.truncated },\n            };","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/plugins/sandbox-providers/createos/src/execute.ts#L142-L178","documentation":"A data event failed the structural validation of its payload fields: `stream` must be exactly \"stdout\" or \"stderr\", and `data_base64` must be a string containing only canonical base64 (with optional padding). Anything else is rejected as corrupt protocol data.","triggerScenarios":"Server emits a stream value like \"std\" or \"fd3\", a missing/null data_base64, or non-canonical base64 (wrong alphabet, whitespace, URL-safe characters, stray padding).","commonSituations":"CreateOS protocol version mismatch adding new stream kinds; a proxy re-encoding base64 (e.g. URL-safe variant); server bug emitting unencoded or partially encoded bytes.","solutions":["Log the offending event and compare its shape with the documented data-event schema.","Align the CreateOS service version with the plugin's protocol expectations.","Remove/repair any intermediary that rewrites base64 payloads or stream names.","Re-run the command; treat the prior process output as untrusted.","Report persistent violations upstream — this indicates server-side protocol corruption."],"exampleFix":"// before\n{ \"type\": \"data\", \"seq\": 3, \"stream\": \"std_out\", \"data_base64\": \"a Gk=\" }\n// after\n{ \"type\": \"data\", \"seq\": 3, \"stream\": \"stdout\", \"data_base64\": \"aGk=\" }","handlingStrategy":"validation","validationCode":null,"typeGuard":"function isValidDataEvent(e: Record<string, unknown>): boolean {\n  return (e.stream === \"stdout\" || e.stream === \"stderr\")\n    && typeof e.data_base64 === \"string\"\n    && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e.data_base64);\n}","tryCatchPattern":"try { await execute(client, params, signal); }\ncatch (e) {\n  if (e instanceof Error && e.message === \"CreateOS process output is invalid.\") {\n    // capture the event shape for a protocol-bug report; re-run the command\n  } else throw e;\n}","preventionTips":["Match the CreateOS service version to the plugin's expected schema.","Prevent proxies from re-encoding base64 payloads (no URL-safe variants).","Schema-test stream events in CI against the documented data event.","Report recurring violations upstream as server-side corruption."],"tags":["protocol","base64","streaming"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}