Skip to content

feat(cubesql): Universally prefix all errors - #10758

Merged
MazterQyou merged 1 commit into
masterfrom
cubesql/error-prefixing
May 27, 2026
Merged

MazterQyou merged 1 commit into
masterfrom
cubesql/error-prefixing

Conversation

@MazterQyou

Copy link
Copy Markdown
Member

Check List

  • Tests have been run in packages where changes have been made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made

This PR makes an effort to universally prefix all errors with preset messages, and unwrap error onions wherever possible.

@MazterQyou
MazterQyou requested review from a team as code owners April 28, 2026 10:42
@github-actions github-actions Bot added the rust Pull requests that update Rust code label Apr 28, 2026
@claude

claude Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MazterQyou's task in 6m 3s —— View job


Code Review: Universally prefix all errors

  • Gather context and read changed files
  • Review core error infrastructure (error.rs, compile/error.rs)
  • Review Postgres error handling changes
  • Review backend-native transport changes
  • Review test and snapshot changes
  • Post comprehensive review feedback

Summary

This is a well-structured PR that introduces a systematic error taxonomy across CubeSQL. The core idea — replacing the old 2-variant User/Internal classification with 10 specific error categories and adding uniform Display prefixes — is sound and addresses a real observability gap.

What works well

  1. Error onion unwrapping: The new From<DataFusionError> and From<ArrowError> implementations properly unwrap nested error types (Plan, Execution, SQL, NotImplemented, etc.) into the correct CubeSQL categories instead of flattening everything to Internal. This preserves valuable context.

  2. ContinueWait as a typed variant: Replacing fragile e.message.to_lowercase().contains("continue wait") string checks with a proper ContinueWait enum variant is a significant reliability improvement.

  3. Bidirectional From conversions: Adding From<CubeError> for CompilationError alongside the existing reverse direction enables the ? operator to work naturally, eliminating many .map_err(|e| CompilationError::internal(e.to_string())) wrappers that were flattening error context.

  4. meta() accessor: The CubeErrorCauseType::meta() helper cleanly centralizes the metadata extraction pattern.

  5. Postgres error code mapping consolidation: The old df_to_error_response/arrow_to_error_response recursive unwrapping chain is replaced by converting to CubeError first and mapping cause types to PG codes. Much cleaner.

  6. Error reclassification: Correct fixes like CubeError::user → CubeError::internal for transport parsing failures, JS bridge deserialization errors, and "unexpected response" errors. These are genuinely internal issues, not user-caused.

Issues & suggestions

Medium priority:

  • http_error.rs catch-all hides user-actionable errors — The _ => "Internal Server Error" catch-all now covers SQLParser, Planning, and Unsupported errors which contain user-actionable information. If this HTTP gateway is user-facing, consider allowing these categories to expose their messages. See inline comment.

  • PG error code for Planning errors — SyntaxErrorOrAccessRuleViolation (42000) may not be the best fit for all planning errors (e.g., join validation failures, missing cube members). See inline comment.

Low priority / nits:

  • Variant naming convention — RESTAPI and SQLParser don't follow Rust PascalCase convention. See inline comment.

  • Boilerplate growth — Each CompilationError method (PartialEq, to_backtrace, message, with_message, with_meta) repeats the full variant list. A macro could reduce this. See inline comment.

  • Minor double-description — rust_decimal::Error formats as "Internal Error: Decimal Error: ...". See inline comment.

Testing

The test changes look correct:

  • Error message assertions updated to match new prefix format (e.g., "Planning Error: ..." instead of "Error during planning: SQLCompilationError: Internal: ...")
  • Snapshot files updated consistently
  • The message() method continues to return the raw message without prefix, while to_string()/Display includes the prefix — test assertions use the right one

Security

No security concerns. The http_error.rs catch-all correctly hides non-User error details from HTTP responses, preventing information leakage.

Overall

Solid improvement to error handling infrastructure. The error taxonomy is well-thought-out and the conversion pipelines are correct. The main risk area is ensuring downstream consumers (logs, HTTP responses, PG wire protocol) get the right level of detail — the inline comments highlight the specific spots to verify.

Comment thread rust/cubesql/cubesql/src/error.rs Resolved
Comment thread rust/cubesql/cubesql/src/error.rs Resolved
Comment on lines 82 to 120
CompilationError::User(right, _) => left == right,
_ => false,
},
CompilationError::RESTAPI(left, _) => match other {
CompilationError::RESTAPI(right, _) => left == right,
_ => false,
},
CompilationError::SQLParser(left, _) => match other {
CompilationError::SQLParser(right, _) => left == right,
_ => false,
},
CompilationError::Unsupported(left, _) => match other {
CompilationError::Unsupported(right, _) => left == right,
_ => false,
},
CompilationError::Planning(left, _) => match other {
CompilationError::Planning(right, _) => left == right,
_ => false,
},
CompilationError::PostProcessing(left, _) => match other {
CompilationError::PostProcessing(right, _) => left == right,
_ => false,
},
CompilationError::Rewrite(left, _) => match other {
CompilationError::Rewrite(right, _) => left == right,
_ => false,
},
CompilationError::DatabaseExecution(left, _) => match other {
CompilationError::DatabaseExecution(right, _) => left == right,
_ => false,
},
CompilationError::Fatal(left, _) => match other {
CompilationError::Fatal(right, _) => left == right,
_ => false,
},
CompilationError::ContinueWait => matches!(other, CompilationError::ContinueWait),
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: consider a macro or helper for PartialEq — This block is very repetitive. Each new variant adds 3 lines of identical structure. A macro like:

macro_rules! match_variant_eq {
    ($self:expr, $other:expr, $($Variant:ident),+) => {
        match ($self, $other) {
            $( (CompilationError::$Variant(left, ..), CompilationError::$Variant(right, ..)) => left == right, )+
            (CompilationError::ContinueWait, CompilationError::ContinueWait) => true,
            _ => false,
        }
    }
}

could reduce this significantly. Same applies to to_backtrace(), to_backtrace_mut(), message(), with_message(), and with_meta(). Not blocking — just noting that the boilerplate will grow linearly with each new error variant.

Comment thread rust/cubesql/cubesql/src/error.rs Resolved
@codecov

codecov Bot commented May 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.12888% with 276 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.82%. Comparing base (9268376) to head (f9b2ec4).

Files with missing lines Patch % Lines
rust/cubesql/cubesql/src/error.rs 25.58% 96 Missing ⚠️
rust/cubesql/cubesql/src/compile/error.rs 18.96% 94 Missing ⚠️
rust/cubesql/cubesql/src/sql/postgres/error.rs 40.54% 22 Missing ⚠️
rust/cubesql/cubesql/src/sql/postgres/shim.rs 33.33% 12 Missing ⚠️
...t/cubesql/cubesql/src/compile/engine/df/wrapper.rs 11.11% 8 Missing ⚠️
...t/cubesql/cubesql/src/compile/rewrite/converter.rs 55.55% 8 Missing ⚠️
rust/cubesql/cubesql/src/compile/query_engine.rs 72.00% 7 Missing ⚠️
...sql/cubesql/src/compile/rewrite/rules/old_split.rs 0.00% 7 Missing ⚠️
rust/cubesql/cubesql/src/transport/service.rs 25.00% 6 Missing ⚠️
rust/cubesql/cubesql/src/compile/engine/df/scan.rs 50.00% 3 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10758      +/-   ##
==========================================
- Coverage   78.93%   78.82%   -0.12%     
==========================================
  Files         470      470              
  Lines       92868    93066     +198     
  Branches     3450     3450              
==========================================
+ Hits        73307    73356      +49     
- Misses      19056    19205     +149     
  Partials      505      505              
Flag Coverage Δ
cube-backend 58.42% <ø> (ø)
cubesql 83.37% <34.12%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MazterQyou
MazterQyou force-pushed the cubesql/error-prefixing branch from b790e17 to b8c91d1 Compare May 6, 2026 15:22
Signed-off-by: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com>
@MazterQyou
MazterQyou force-pushed the cubesql/error-prefixing branch from b8c91d1 to f9b2ec4 Compare May 21, 2026 16:20
@MazterQyou
MazterQyou merged commit 6c13990 into master May 27, 2026
169 of 172 checks passed
@MazterQyou
MazterQyou deleted the cubesql/error-prefixing branch May 27, 2026 14:57

This branch was successfully deployed

1 active deployment
Preview — f9b2ec4c Deployed May 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ Proxy