Skip to content

Report stored-hierarchy corruption as an internal error, not invalid_argument #2425

Closed

Description

@malibio

Problem

NodeServiceError::CircularReference and NodeServiceError::HierarchyViolation both map through OpsError::ValidationFailed (packages/core/src/ops/mod.rs:78-83) to Status::invalid_argument.

That classification is correct for the write paths that raise these variants — is_descendant on move and validate_no_member_of_cycle — where the caller genuinely proposed the cycle and invalid_argument accurately says "your request was bad, don't retry it as-is".

It is misleading for the read path. get_children_tree → build_node_tree_recursive now raises the same variants when the persisted graph contains a cyclic or pathologically deep has_child edge. There the caller's request is perfectly valid; the stored data is not. Consequences:

  • invalid_argument tells the client to fix its request, but retrying identically fails identically — there is nothing the caller can change.
  • Server-side data corruption does not show up in server-error dashboards, because it is reported as a client error.

Precedent

packages/daemon/src/services/node_service.rs:1371-1376 already draws exactly this distinction for a schema node that exists but fails to parse — "a stored-data bug, not a caller error" → Status::internal.

Why this wasn't fixed inline

Surfaced during review of the PR that added the read-path guards. Both variants are raised in nine places across hierarchy.rs, nearly all of them write paths where the current mapping is right. Remapping the variants globally would wrongly reclassify those, so an honest fix needs a distinct error variant (e.g. one meaning "stored hierarchy is corrupt") threaded through NodeServiceError → OpsError → the status mapper. That is shared error plumbing and warranted its own change rather than a rider on the guard PR.

Suggested fix

Add a NodeServiceError variant for stored-data corruption, raise it from the two guards in build_node_tree_guarded (packages/core/src/services/node_service/mod.rs), and map it to Status::internal — leaving the write-path variants mapping to invalid_argument as they do now.

Acceptance criteria

  • A cyclic or over-deep stored hierarchy surfaces to the gRPC client as internal, not invalid_argument
  • Write-path cycle rejection (move/reorder, member_of) still surfaces as invalid_argument
  • The distinction is covered by a test at the mapping layer

Activity

  1. added a commit that references this issue on Sep 7, 2026
    6168061
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions