feat: actually using namespace error variants#6275
feat: actually using namespace error variants#6275wjones127 merged 10 commits intolance-format:mainfrom
Conversation
PR ReviewClean, mechanical migration from generic P1: REST client maps all HTTP errors to
|
|
Mentioning parallel work that updates to throw on |
|
Another effort to add |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace generic lance_core::Error variants (invalid_input_source, io_source, not_supported_source, etc.) with NamespaceError variants throughout the namespace-impls crate. This ensures errors flow through the LanceError::Namespace path and get properly converted to lance_namespace.errors Python exceptions with correct error codes. Also fix table_exists fallback to only fall through to directory check for single-level IDs, matching the existing describe_table pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jackye1995
left a comment
There was a problem hiding this comment.
thanks, long overdue. I think the title should be feat or fix, not chore since it changes user experience.
wjones127
left a comment
There was a problem hiding this comment.
This seems good, but I'm noting there is a pre-existing issue where the NamespaceError has Display implementations and message fields. Most of the time, they seem to duplicate information. I've noted two cases of this, but here are several more. I'd consider cleaning those up, either here or in a follow up.
| None => Err(NamespaceError::NamespaceNotFound { | ||
| message: format!("Namespace '{}' not found", object_id), | ||
| } | ||
| .into()), |
There was a problem hiding this comment.
suggestion: This message duplicates what is in the Display implementation for this error:
lance/rust/lance-namespace/src/error.rs
Lines 180 to 182 in baa13ab
The error will print as:
Namespace not found: Namespace '{name}' not found
Consider just putting the quoted object id as the message:
| None => Err(NamespaceError::NamespaceNotFound { | |
| message: format!("Namespace '{}' not found", object_id), | |
| } | |
| .into()), | |
| Err(NamespaceError::NamespaceNotFound { | |
| message: format!("'{}'", object_id) | |
| } | |
| .into()) |
Then the message would be like:
Namespace not found: '{name}'
There was a problem hiding this comment.
You could also change the error itself to table a table name instead of a custom message.
There was a problem hiding this comment.
Great call out. I updated all of these that I could find. But just like replacing all the errors, I'm sure I missed one and will have to come back and fix it 😆
| return Err(NamespaceError::NamespaceAlreadyExists { | ||
| message: format!("Namespace '{}' already exists", object_id), | ||
| } | ||
| .into()); |
There was a problem hiding this comment.
issue(non-blocking): similar problem here: message duplicates the Display implementations of NamespaceError::NamespaceAlreadyExists:
lance/rust/lance-namespace/src/error.rs
Lines 184 to 186 in baa13ab
The Display impl on NamespaceError variants already adds context like "Namespace not found: " or "Table already exists: ", so messages should contain just the entity identifier rather than repeating the variant semantics (e.g. "Namespace 'foo' not found"). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The REST server was serializing ns_err.to_string() (which includes the Display prefix) as the error message. The client then wrapped that full string back into a new NamespaceError, causing doubled prefixes like "Namespace not empty: Namespace not empty: ...". Use the new message() accessor to send just the inner message without the Display prefix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In the rust SDK we have a `NamespaceError` that contains a message and an error code. Additionally, in both the Java and python SDKs we have logic to parse this type (and error codes) to produce native Java exceptions. The problem, is that in the `namespace-impls` we are never using them. Therefore the rust `NamespaceError` type is never used and the Java / python SDK conversion code the parse and throw native errors is essentially dead code. In this PR, we update the `namespace-impls` to actually throw the correct error types. Closes lance-format#6240 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In the rust SDK we have a
NamespaceErrorthat contains a message and an error code. Additionally, in both the Java and python SDKs we have logic to parse this type (and error codes) to produce native Java exceptions. The problem, is that in thenamespace-implswe are never using them. Therefore the rustNamespaceErrortype is never used and the Java / python SDK conversion code the parse and throw native errors is essentially dead code. In this PR, we update thenamespace-implsto actually throw the correct error types.Closes #6240