[codex] Structure project and filesystem RPC errors#3400
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
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 |
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: Search failures omit normalizedCwd
- Added
normalizedCwd: error.cwdto the three search-index error branches (WorkspaceSearchIndexCreateFailed, WorkspaceSearchIndexScanTimedOut, WorkspaceSearchIndexSearchFailed) in projectEntriesFailureContext, matching how workspace-root errors already propagate the normalized path.
- Added
Or push these changes by commenting:
@cursor push 594471e8fd
Preview (594471e8fd)
diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts
--- a/apps/server/src/ws.ts
+++ b/apps/server/src/ws.ts
@@ -155,11 +155,23 @@
normalizedCwd: error.normalizedWorkspaceRoot,
};
case "WorkspaceSearchIndexCreateFailed":
- return { failure: "search_index_create_failed", detail: error.reason };
+ return {
+ failure: "search_index_create_failed",
+ normalizedCwd: error.cwd,
+ detail: error.reason,
+ };
case "WorkspaceSearchIndexScanTimedOut":
- return { failure: "search_index_scan_timed_out", timeout: error.timeout };
+ return {
+ failure: "search_index_scan_timed_out",
+ normalizedCwd: error.cwd,
+ timeout: error.timeout,
+ };
case "WorkspaceSearchIndexSearchFailed":
- return { failure: "search_index_search_failed", detail: error.reason };
+ return {
+ failure: "search_index_search_failed",
+ normalizedCwd: error.cwd,
+ detail: error.reason,
+ };
default:
return unexpectedCompatibilityError(error);
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 13e6969. Configure here.
Co-authored-by: codex <codex@users.noreply.github.com>
ApprovabilityVerdict: Approved This PR refactors RPC error handling to use structured error types instead of string messages, without changing when errors occur or how operations behave. Backward compatibility is preserved for rolling upgrades, and tests cover both new structure and legacy decoding paths. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate 7ae0764
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate c447448
d2e1471
into
codex/structure-workspace-filesystem-errors


Summary
Project search/list, workspace file read/write, and filesystem browse RPC failures previously collapsed rich server-side errors into message strings, often by interpolating an underlying cause. Clients and telemetry could not reliably correlate failures by operation or path, and platform details leaked into user-facing messages.
This change adds rolling-compatible structured diagnostics to the existing RPC error tags. New failures carry the request context, a closed failure classification, relevant normalized/resolved paths, file operations, and the exact underlying cause. Messages are derived from stable request attributes and no longer depend on cause text. Legacy message-only payloads still decode during rolling upgrades.
The server boundary now maps internal workspace error unions into those fields exhaustively. Focused contract and websocket tests cover stable messages, retained causes, structured fields, and legacy decoding.
Stacked on #3274 because it consumes the structured workspace filesystem errors introduced there.
Validation
vp test packages/contracts/src/project.test.ts packages/contracts/src/filesystem.test.ts apps/server/src/server.test.ts(101 tests)vp checkvp run typecheckSensitive-context follow-up\n- project-search RPC errors retain query length rather than the raw query\n- legacy message-only and legacy raw-query payloads continue decoding during rolling upgrades without retaining the query\n- server mappings preserve the exact underlying cause
Note
Medium Risk
Changes the RPC error wire format and user-visible messages for workspace operations; clients or telemetry that parsed legacy message strings may need updates, though structured fields improve safe handling.
Overview
Workspace project and filesystem browse RPC failures now return structured error payloads instead of long message strings built from underlying causes.
Contract error types gain typed
failurediscriminators plus request context (cwd,relativePath,queryLengthinstead of raw query, paths, operations, etc.). User-facingmessagestrings are derived from that context and no longer echo cause text—so search queries, file contents, and platform details stay out of messages whilecauseis still attached for debugging. Message-only legacy payloads remain decodable for rolling upgrades.The websocket layer maps internal workspace error unions into those fields exhaustively and drops the old compatibility string builders. Integration tests assert the new shape, including that sensitive search text never appears on the wire.
Reviewed by Cursor Bugbot for commit c447448. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure filesystem and project RPC errors with typed classes and contextual fields
ProjectSearchEntriesError,ProjectListEntriesError,ProjectReadFileError,ProjectWriteFileError,FilesystemBrowseError) in project.ts and filesystem.ts with structured fields (cwd, relativePath, failure codes, etc.).projectEntriesFailureContext,filesystemBrowseFailureContext,projectFileFailureContext).Macroscope summarized c447448.