{"record":{"id":"3f294ddf49747a35","repo":"paperclipai/paperclip","slug":"createos-process-sequence-is-invalid","errorCode":null,"errorMessage":"CreateOS process sequence is invalid.","messagePattern":"CreateOS process sequence is invalid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/createos/src/execute.ts","lineNumber":154,"sourceCode":"      signal.throwIfAborted();\n      let response: Response;\n      try {\n        response = await client.request(`${base}/${processId}/connect?after=${cursor}`, { signal });\n      } catch (error) {\n        if (error instanceof CreateosApiError && error.status === 410) {\n          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();","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/plugins/sandbox-providers/createos/src/execute.ts#L136-L172","documentation":"A `data` event on the process output stream carried a `seq` that is not a positive safe integer. The plugin validates sequence numbers strictly to guarantee ordered, gap-free output; a malformed seq means the server is violating the protocol, so it fails closed instead of guessing.","triggerScenarios":"CreateOS (or an intermediary rewriting the stream) emits a data event with a missing/non-numeric seq, a float, 0, a negative value, or an unsafe integer beyond Number.MAX_SAFE_INTEGER.","commonSituations":"Protocol drift between plugin and a newer/older CreateOS service; a bug or memory corruption server-side; a man-in-the-middle or proxy rewriting event payloads.","solutions":["Capture the raw frame and confirm the seq field's actual value/type against the expected protocol.","Pin/align the CreateOS service version with the plugin's expected protocol.","Check for intermediaries (proxies, transforms) altering event JSON in transit.","Retry once to rule out a transient glitch; persistent failures indicate server-side protocol bugs — report upstream.","Treat the run as failed and re-execute; never skip or fabricate sequence numbers."],"exampleFix":"// before (server bug)\n{ \"type\": \"data\", \"stream\": \"stdout\", \"data_base64\": \"aGk=\" }        // seq missing\n// after\n{ \"type\": \"data\", \"seq\": 7, \"stream\": \"stdout\", \"data_base64\": \"aGk=\" }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasValidSeq(e: unknown): e is { type: \"data\"; seq: number } {\n  return typeof e === \"object\" && e !== null && \"seq\" in e\n    && typeof (e as any).seq === \"number\" && Number.isSafeInteger((e as any).seq) && (e as any).seq >= 1;\n}","tryCatchPattern":"try { await execute(client, params, signal); }\ncatch (e) {\n  if (e instanceof Error && e.message === \"CreateOS process sequence is invalid.\") {\n    // protocol violation: capture diagnostics, re-run once, then escalate\n  } else throw e;\n}","preventionTips":["Keep plugin and CreateOS service versions protocol-aligned.","Remove intermediaries that rewrite stream JSON.","Alert on this error — it indicates server-side protocol bugs, not client issues.","Integration-test stream events against the documented schema."],"tags":["protocol","streaming","sequence"],"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"}