Skip to content

feat: return Unprocessable error while expected error happened#5347

Merged
Xuanwo merged 5 commits intomainfrom
Xuanwo/indexer-precheck-warning
Nov 27, 2025
Merged

feat: return Unprocessable error while expected error happened#5347
Xuanwo merged 5 commits intomainfrom
Xuanwo/indexer-precheck-warning

Conversation

@Xuanwo
Copy link
Copy Markdown
Collaborator

@Xuanwo Xuanwo commented Nov 26, 2025

This PR intends to return Unprocessable error while expected error happened. In this way, our users can print helpful message to users instead of just return the Index error.


This PR was primarily authored with Codex using GPT-5-Codex and then hand-reviewed by me. I AM responsible for every change made in this PR. I aimed to keep it aligned with our goals, though I may have missed minor issues. Please flag anything that feels off, I'll fix it quickly.

Signed-off-by: Xuanwo <github@xuanwo.io>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 26, 2025
Signed-off-by: Xuanwo <github@xuanwo.io>
Copy link
Copy Markdown
Member

@westonpace westonpace left a comment

Choose a reason for hiding this comment

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

I agree that Error::Index is not terribly useful here but I wonder if we need a new error type?

Comment thread rust/lance-core/src/error.rs Outdated
Comment on lines +66 to +67
#[snafu(display("Precondition failed: {message}, {location}"))]
Precondition { message: String, location: Location },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is Precondition meaningfully different from InvalidInput?

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.

Yes, Precondition here follows the same pattern as HTTP Status 412 Precondition, used by many services to indicate that the request itself is valid but the condition is not met. In this case, the dataset doesn’t have enough data. I wish this error could be used by users to identify these cases instead of bypassing real invalid input errors.

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.

What about just saying it is unsupported? since this after all is us not able to support building/refreshing the index with this amount of data.

@Xuanwo
Copy link
Copy Markdown
Collaborator Author

Xuanwo commented Nov 26, 2025

cc @BubbleCal, maybe you will be interested in this PR.

Copy link
Copy Markdown
Member

@westonpace westonpace left a comment

Choose a reason for hiding this comment

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

My only nit with 412 is that it is normally used where the caller provides the preconditions (e.g. if-... headers). I think HTTP 422 (unprocessable) might be slightly more accurate. However, we are well into bike-shedding at this point so I'll trust your judgement.

Copy link
Copy Markdown
Contributor

@BubbleCal BubbleCal left a comment

Choose a reason for hiding this comment

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

I think we do error mapping somewhere else (e.g. lancedb), we may need to add a new map for Precondition

@Xuanwo
Copy link
Copy Markdown
Collaborator Author

Xuanwo commented Nov 27, 2025

My only nit with 412 is that it is normally used where the caller provides the preconditions (e.g. if-... headers). I think HTTP 422 (unprocessable) might be slightly more accurate. However, we are well into bike-shedding at this point so I'll trust your judgement.

Oh, I learned a new HTTP status code. After some thought, I think unprocessable better matches our semantics here, will add a patch for this.

@Xuanwo Xuanwo changed the title feat: return Precondition error while expected error happened feat: return Unprocessable error while expected error happened Nov 27, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 78.37838% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance-index/src/vector/kmeans.rs 0.00% 6 Missing ⚠️
rust/lance/src/index.rs 50.00% 0 Missing and 1 partial ⚠️
rust/lance/src/index/vector/pq.rs 96.29% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Xuanwo Xuanwo merged commit d4836fd into main Nov 27, 2025
23 of 26 checks passed
@Xuanwo Xuanwo deleted the Xuanwo/indexer-precheck-warning branch November 27, 2025 08:42
@westonpace
Copy link
Copy Markdown
Member

Oh, I learned a new HTTP status code.

To be fair, I had to look it up 😆 I thought I remembered something like this but just couldn't remember the actual words.

jackye1995 pushed a commit to jackye1995/lance that referenced this pull request Jan 21, 2026
…-format#5347)

This PR intends to return Unprocessable error while expected error
happened. In this way, our users can print helpful message to users
instead of just return the Index error.

---

**This PR was primarily authored with Codex using GPT-5-Codex and then
hand-reviewed by me. I AM responsible for every change made in this PR.
I aimed to keep it aligned with our goals, though I may have missed
minor issues. Please flag anything that feels off, I'll fix it
quickly.**

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants