[codex] Structure ACP transport errors#3251
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Refactoring of ACP transport error handling to use structured fields instead of free-form strings. No behavioral changes beyond error message formatting, with added benefit of preventing sensitive values from leaking into error messages. Comprehensive test coverage included. You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate 8538a20
Dismissing prior approval to re-evaluate 90d09c7
Dismissing prior approval to re-evaluate 0009907
Dismissing prior approval to re-evaluate 62b4eb4
Dismissing prior approval to re-evaluate 625a431
Dismissing prior approval to re-evaluate 8c20ca7
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
8c20ca7 to
e545938
Compare
Dismissing prior approval to re-evaluate e545938
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Core handlers get extension errors
- Replaced the misuse of fromHandlerError in runHandler with inline logic that produces core-appropriate error message ('ACP request handler failed') and operation tag ('handle-request') instead of the extension-specific wording.
Or push these changes by commenting:
@cursor push f1de956242
Preview (f1de956242)
diff --git a/packages/effect-acp/src/_internal/shared.ts b/packages/effect-acp/src/_internal/shared.ts
--- a/packages/effect-acp/src/_internal/shared.ts
+++ b/packages/effect-acp/src/_internal/shared.ts
@@ -35,9 +35,17 @@
return yield* Effect.fail(AcpError.AcpRequestError.methodNotFound(method).toProtocolError());
}
return yield* handler(payload).pipe(
- Effect.mapError((error) =>
- AcpError.AcpRequestError.fromHandlerError(error, method).toProtocolError(),
- ),
+ Effect.mapError((error) => {
+ const requestError =
+ error._tag === "AcpRequestError"
+ ? error
+ : AcpError.AcpRequestError.internalError(
+ `ACP request handler failed for method '${method}'`,
+ undefined,
+ { method, operation: "handle-request", cause: error },
+ );
+ return requestError.toProtocolError();
+ }),
);
});
diff --git a/packages/effect-acp/src/errors.test.ts b/packages/effect-acp/src/errors.test.ts
--- a/packages/effect-acp/src/errors.test.ts
+++ b/packages/effect-acp/src/errors.test.ts
@@ -96,7 +96,7 @@
expect(error).toMatchObject({
code: -32603,
- message: "ACP extension request handler failed for method 'fs/read_text_file'",
+ message: "ACP request handler failed for method 'fs/read_text_file'",
});
expect(error.message).not.toContain(cause.message);
});
diff --git a/packages/effect-acp/src/errors.ts b/packages/effect-acp/src/errors.ts
--- a/packages/effect-acp/src/errors.ts
+++ b/packages/effect-acp/src/errors.ts
@@ -6,6 +6,7 @@
export const AcpRequestOperation = Schema.Literals([
"decode-extension-request-payload",
"handle-extension-request",
+ "handle-request",
]);
export type AcpRequestOperation = typeof AcpRequestOperation.Type;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit e545938. Configure here.
Co-authored-by: codex <codex@users.noreply.github.com>


Summary
Validation
Note
Medium Risk
Error shapes and user-visible messages change across the ACP client/agent stack, which may break callers that match on message text; the changes are security-motivated (avoid leaking payload/cause details) and are covered by new and updated tests.
Overview
Restructures ACP transport, protocol parse, and request errors so public
messagestrings are fixed templates with optionaloperationandmethodfields, while the originalcause(RPC, stream,SchemaError, etc.) is preserved on the error object.Schema validation failures no longer embed formatted issue text or raw invalid values in messages, logs, or JSON-RPC
data. Instead they attach summarized diagnostics (issueCount,issueKinds,maximumPathDepth) via shared helpers onAcpProtocolParseErrorandAcpRequestError, with full details only on theSchemaErrorcause.Protocol and RPC plumbing passes RPC method names into
callRpc, maps handler failures throughfromCoreHandlerError/fromExtensionHandlerError, logs decode failures with operation metadata only, uses stable RpcClient defect messages for termination and send failures, and treats a clean stdin end asAcpInputStreamEndedErrorinstead of a synthetic transport error.API cleanup: removes
makeTerminal; the agent builds terminal handles as plainAcpTerminal-shaped objects. Addserrors.test.tsand extends protocol/client tests for the new error behavior.Reviewed by Cursor Bugbot for commit 2b3948b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure ACP transport, request, and protocol parse errors with operation and method context
detailstrings onAcpTransportError,AcpProtocolParseError, andAcpRequestErrorwith structuredoperationandmethodfields, standardizing all user-facing error messages.schemaIssueDiagnosticsto aggregate schema issue counts, kinds, and path depth into error metadata without leaking raw payload values.AcpInputStreamEndedErroras a distinct error type for end-of-input conditions, replacing ad-hocAcpTransportErrorconstruction.makeTerminalfrom terminal.ts and thenormalizeToRequestError/toRpcClientErrorhelpers from protocol.ts; callers must construct terminal objects directly.callRpcnow requires an explicit method string as its first argument — call sites in agent.ts and client.ts are updated accordingly.Macroscope summarized 2b3948b.