Repository navigation
B6: Exhaustive NodeServiceError→gRPC error mapping + parity tests - #1257
Conversation
) Replace catch-all `other => OpsError::Internal` in `From<NodeServiceError> for OpsError` with explicit arms for all remaining variants: `InvalidUpdate` → `ValidationFailed` (client error → `InvalidArgument`); genuinely internal variants (`DatabaseError`, `TransactionFailed`, `SerializationError`, `QueryFailed`, `BulkOperationFailed`, `InitializationError`) mapped explicitly to `Internal`; collection-validation variants (`InvalidCollectionPath`, `CollectionCycle`, `CollectionDepthExceeded`) → `ValidationFailed`. `ValidationFailed` in `ops_error_to_status` now maps to `invalid_argument` instead of `failed_precondition`. `fetch_node` routes through `service_error_to_status` instead of a bare `Status::internal`. Adds 19 table-driven parity tests asserting every variant's `tonic::Code`. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review — Initial ReviewReview Type: Initial Review Requirements Check (Issue #1254)
Code Review Findings🟡 Important: ExportMarkdown catch-all at line 670 was not converted📁 packages/daemon/src/services/node_service.rs:665-670 The issue (acceptance criterion 4) required auditing all
Recommendation: Make this match arm exhaustive by adding an arm for MarkdownError::CreationFailed(m) => Status::failed_precondition(format!("Node creation failed: {m}")),
MarkdownError::Internal(m) => Status::internal(format!("ExportMarkdown failed: {m}")),Engineering principle: Exhaustiveness at error-type boundaries is the defensive posture this issue establishes — it should be applied consistently, not just on the primary error path. 🟡 Important:
|
malibio
left a comment
There was a problem hiding this comment.
See detailed review comment above. Two acceptance-criterion-4 call sites (ExportMarkdown catch-all at line 670, get_nodes_batch bypass at line 711) were not converted to route through service_error_to_status. Quick fixes — otherwise the core deliverable (exhaustive error mapping + 19 parity tests) is well implemented.
…hrough service_error_to_status - ExportMarkdown match now covers all 4 MarkdownError variants explicitly (CreationFailed → failed_precondition, Internal → internal); no catch-all - get_nodes_batch .map_err now routes through service_error_to_status instead of bare Status::internal - PlaybookValidationFailed arm destructures `errors` field directly instead of calling err.to_string() Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
) * B6: Exhaustive NodeServiceError→gRPC error mapping + parity tests (#1254) Replace catch-all `other => OpsError::Internal` in `From<NodeServiceError> for OpsError` with explicit arms for all remaining variants: `InvalidUpdate` → `ValidationFailed` (client error → `InvalidArgument`); genuinely internal variants (`DatabaseError`, `TransactionFailed`, `SerializationError`, `QueryFailed`, `BulkOperationFailed`, `InitializationError`) mapped explicitly to `Internal`; collection-validation variants (`InvalidCollectionPath`, `CollectionCycle`, `CollectionDepthExceeded`) → `ValidationFailed`. `ValidationFailed` in `ops_error_to_status` now maps to `invalid_argument` instead of `failed_precondition`. `fetch_node` routes through `service_error_to_status` instead of a bare `Status::internal`. Adds 19 table-driven parity tests asserting every variant's `tonic::Code`. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Address review: exhaust MarkdownError match + route get_nodes_batch through service_error_to_status - ExportMarkdown match now covers all 4 MarkdownError variants explicitly (CreationFailed → failed_precondition, Internal → internal); no catch-all - get_nodes_batch .map_err now routes through service_error_to_status instead of bare Status::internal - PlaybookValidationFailed arm destructures `errors` field directly instead of calling err.to_string() Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Closes #1254.
Summary
From<NodeServiceError> for OpsError(ops/mod.rs) is now exhaustive — catch-allother => Internalreplaced with explicit arms for every remaining variantInvalidUpdate→ValidationFailed→InvalidArgument(wasInternal)InvalidCollectionPath,CollectionCycle,CollectionDepthExceeded) →ValidationFailed→InvalidArgumentDatabaseError,TransactionFailed,SerializationError,QueryFailed,BulkOperationFailed,InitializationError) mapped explicitly toInternal— compile error on any future unmapped variantops_error_to_status:ValidationFailed→invalid_argument(wasfailed_precondition)fetch_noderoutes throughservice_error_to_statusinstead of bareStatus::internalNodeServiceErrorvariant →tonic::Codefor every variantTest plan
cargo test -p nodespace-daemon— 19 newerror_mapping_*tests passcargo test --workspace --exclude nodespace-agent— all green (agent/Ollama tests require live Ollama, pre-existing skip)cargo clippy --workspace --all-targets -- -D warnings— clean🤖 Generated with Claude Code