Repository navigation
fix(sea): propagate status-level SQLSTATE - #259
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
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>
ce1da8c to
dad9961
Compare
There was a problem hiding this comment.
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.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
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.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
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).
| /// `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( |
There was a problem hiding this comment.
🔵 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.
There was a problem hiding this comment.
sql state should be derived from statementstatus directly, not sure why we use status.error.sql_state previously
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It is fine, we should use status.sql_state as the source of truth for SEA path
There was a problem hiding this comment.
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.
Reyden and newer DBSQL SEA responses return SQLSTATE on
status.sql_state. The kernel previously looked forstatus.error.sql_statebefore parsingstatus.error.message.Update synchronous and asynchronous statement failures to prefer
status.sql_state, then fall back to extracting SQLSTATE fromstatus.error.message.status.error.sql_stateis not used. The separate non-2xx HTTP error decoder is unchanged.Validated with formatting, Clippy, focused unit tests, and sync/async WireMock regressions.