Skip to content

Conversation

@Xuanwo
Copy link
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.

@github-actions github-actions bot added the enhancement New feature or request label Nov 26, 2025
Signed-off-by: Xuanwo <[email protected]>
Copy link
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 on lines 66 to 67
#[snafu(display("Precondition failed: {message}, {location}"))]
Precondition { message: String, location: Location },
Copy link
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
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
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
Collaborator Author

Xuanwo commented Nov 26, 2025

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

Copy link
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
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
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

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
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.

5 participants