Repository navigation
fix(services): give every NodeDB error a deliberate category - #11
Merged
Merged
Conversation
nodedb-types 0.6 added error variants that the catch-all arm sent to Server. Each ErrorDetails variant now has an explicit arm in category_of, chosen from what the v0.6.2 server means by it: - Auth: AuthenticationFailed. - NotFound: DatabaseNotFound, UndefinedObject, NotFound. - Conflict: AlreadyExists, DependentObjectsExist, TransactionRollback, CloneDependency, MoveTenantAlreadyAtTarget. - ReadOnly: CloneWriteRequiresMaterialize. - Setup: user SQL errors, statement and tenant limits, and clone, backup and move-tenant refusals the request must change. - Connection: RateExceeded, QuotaExceeded (the connection cap), StaleReadNotLeader, Cluster (a version mismatch). - Server: Dispatch, MemoryExhausted, DeadlineExceeded, and infrastructure faults. ServerOverload and RateExceeded are now retriable, although the client says no. Both are refused before anything runs. Dispatch is not retriable: the server also raises it after a write whose outcome is unknown. The is_retriable doc states that true means transient, not safe to re-send a write. A test walks all 86 codes in ErrorCode::ALL against a table of expected category and retry flag. It fails on a code without an explicit arm, so a crate bump cannot add a code silently. A second test fails when an upstream fix makes a retry override redundant. They replace 11 single-variant mapping tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nodedb-types 0.6 added error variants that
From<NodeDbError> for StudioErrorsent toServerthrough its catch-all arm. Every variant now has a deliberate category and Retry decision, chosen from what the v0.6.2 server means by it.category_of): each of the 85ErrorDetailsvariants has an arm. The required_arm (foreign#[non_exhaustive]enum) catches only variants added after 0.6.2.AuthenticationFailed.DatabaseNotFound,UndefinedObject,NotFound.AlreadyExists,DependentObjectsExist,TransactionRollback,CloneDependency,MoveTenantAlreadyAtTarget.CloneWriteRequiresMaterialize.RateExceeded,QuotaExceeded(the connection cap),StaleReadNotLeader,Cluster(a version mismatch).Dispatch,MemoryExhausted(moved from Connection),DeadlineExceeded, infrastructure faults.studio_retries):ServerOverloadandRateExceededare retriable although the client'sis_retriable()says no. The server refuses both before anything runs.Dispatch: the server also raises it after a write whose outcome is unknown (response channel closed).is_retriabledoc:truemeans transient, not safe to re-send a write.DeadlineExceeded,SyncConnectionFailed,NotLeaderandNodeUnreachableare client-retriable and can each follow a committed write.Tests
every_error_code_has_a_deliberate_category_and_retry_flag: walks all 86 codes inErrorCode::ALLagainst a table of expected category and retry flag. It fails on a code without a row or without an explicit arm, and lists every mismatch in one run.studio_retries_only_what_the_client_does_not: fails when an upstream fix makes an override redundant, so it can be removed.studio_originated_errors_are_not_retriable: covers the four Studio-originated variants.Notes
ErrorCodeis not caught. No test can list the variants of a foreign#[non_exhaustive]enum. Diff nodedb-typeserror/details.rson each crate bump.mark_all_read, so no current Retry is unsafe. Record-write Retry needs a per-operation policy, not this flag alone.Internaland Studio shows "server error". TheAuthenticationFailedarm is correct but does not fire for it. Upstream, not fixable here.NodeUnreachable) keeps its category, so screenshots stay the same.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run: 267 passed