Skip to content

fix(sea): propagate status-level SQLSTATE - #259

Merged
vuanhphung merged 6 commits into
mainfrom
fix/sea-status-sql-state
Aug 18, 2026
Merged

vuanhphung merged 6 commits into
mainfrom
fix/sea-status-sql-state

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Reyden and newer DBSQL SEA responses return SQLSTATE on status.sql_state. The kernel previously looked for status.error.sql_state before parsing status.error.message.

Update synchronous and asynchronous statement failures to prefer status.sql_state, then fall back to extracting SQLSTATE from status.error.message. status.error.sql_state is not used. The separate non-2xx HTTP error decoder is unchanged.

Validated with formatting, Clippy, focused unit tests, and sync/async WireMock regressions.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Medium

Solid, well-tested change that adds the canonical status.sql_state field and prefers it in both sync and async failure paths. One medium concern: the new extraction helper drops the previously-preferred nested status.error.sql_state rung, retaining only message-parsing as fallback — a narrowing that can lose SQLSTATE for responses carrying it only in the structured nested field. Struct/Debug/test wiring is otherwise consistent and correct.

Comment thread src/kernel_error.rs Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 2 High

Mechanically the wiring is sound — the new status.sql_state field deserializes correctly, is preferred, and struct/Debug/test updates are consistent. The concern is behavioral: both failure paths drop the previous SQLSTATE fallbacks (nested error.sql_state and the "SQLSTATE: XXXXX" message parse) despite the PR description claiming those are retained, and the new tests can't detect the loss because they populate both the status field and the message suffix. Resolve the intent (chain the fallbacks, or document/test the narrower behavior).

Comment thread src/client/sea.rs Resolved
Comment thread src/statement/executed_async.rs Resolved
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Medium

Looks good — clean, well-tested change to read SQLSTATE from status.sql_state on both sync and async statement-failure paths. The retired extract_sqlstate_from_message helper and ServiceError.sql_state field remain correctly used by the non-2xx transport decoder, and with_sql_state(&str) type-checks. One medium concern: dropping the message-parse fallback could silently lose SQLSTATE on servers that only embed it in the error message.

Comment thread src/client/sea.rs Resolved
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Medium

Clean, well-scoped fix — adds the canonical status.sql_state SEA field and reads it in both sync and async failure paths; the old helpers stay live in the non-2xx decoder, and tests are updated consistently. One medium concern: dropping the error.sql_state + message-parse fallbacks (rather than layering the new field on top of them) can silently lose SQLSTATE for servers that only populate a legacy location, and the updated fixtures no longer exercise that case.

Comment thread src/client/sea.rs Resolved
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Low

Looks good — clean, well-tested refactor that dedupes SQLSTATE extraction across the sync/async failure paths and correctly threads the new status.sql_state wire field through all struct literals and Debug impls. One low-severity note: the change fully drops reading of the nested status.error.sql_state, which has a narrow edge-case regression risk (mitigated by the message-parse and message-substring fallbacks).

Comment thread src/kernel_error.rs
/// `status.error.message`. The nested `status.error.sql_state` field
/// belongs to the shared transport-error shape and is intentionally
/// ignored for statement failures.
pub(crate) fn extract_sqlstate_from_status(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — extract_sqlstate_from_status now reads only top-level status.sql_state then falls back to parsing status.error.message. The prior code (both sync and async paths) also consulted the nested status.error.sql_state field; that path is now dropped entirely.

This is deliberate and documented, and the message-parsing fallback plus the message-substring branch in is_object_not_found mitigate most cases. But there is a narrow regression window: a server (e.g. an older DBSQL response) that reports SQLSTATE only in status.error.sql_state — with no top-level sql_state and no SQLSTATE: XXXXX substring in the message — would now silently lose the SQLSTATE. For metadata fan-out that specifically means a 42704 object-not-found delivered only in the nested field would no longer be recognized as not-found (via the SQLSTATE path), so list_tables wildcard enumeration would propagate the error instead of skipping the dropped catalog.

If you've confirmed no live/older server populates only the nested field for statement failures, this is fine as-is — worth a one-line note in the PR that the drop was validated against those responses, since the moved wiremock fixtures previously exercised the nested placement.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sql state should be derived from statementstatus directly, not sure why we use status.error.sql_state previously

https://docs.google.com/document/d/1xAt_7rPhnZItK75xh8WwEKDSSzd6cdlBxZzFagabAyA/edit?tab=t.0#heading=h.5key87w8p5td

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That design principle is reasonable — deriving SQLSTATE from StatementStatus.sql_state as the canonical source is cleaner than reaching into the transport-error shape, and the comment now documents that intent well. The reason the old code consulted status.error.sql_state is that it's the shared transport-error field, which older/edge DBSQL responses could populate instead of the top-level one. My concern isn't the design direction — it's the narrow behavioral case where a server delivers a 42704 only in the nested field with no SQLSTATE: substring in the message, which would now bypass the not-found recognition in metadata fan-out. The current code still reads only status.sql_state, so that gap is unaddressed. This stays a Low; a one-line PR note confirming the drop was validated against the older-response fixtures (the ones the wiremock move previously exercised) would close it out.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It is fine, we should use status.sql_state as the source of truth for SEA path

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The design direction here is sound — treating StatementStatus.sql_state as the canonical source for the SEA path is cleaner than reaching into the transport-error shape, and I don't dispute that. My residual point was narrower and empirical: whether any older/edge DBSQL response delivers a 42704 only in status.error.sql_state with no top-level sql_state and no SQLSTATE: substring, which would slip past not-found recognition in metadata fan-out. The current code still reads only status.sql_state, so that gap isn't closed by the design rationale alone. This stays a non-blocking Low — a one-line note confirming the drop was validated against the older-response fixtures the wiremock move previously exercised would fully settle it, and I'm leaving the thread open for that.

@vuanhphung
vuanhphung added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 7c08729 Aug 18, 2026
28 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — b2cd3f44 Deployed Aug 18, 2026 by oss-reviewer-bot[bot] via followup #479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants