Skip to content

Add a distinct exception for generative query failures - #2210

Merged
dirkkul merged 2 commits into
weaviate:mainfrom
karthiksenv:codex/generative-query-error
Nov 12, 2026
Merged

dirkkul merged 2 commits into
weaviate:mainfrom
karthiksenv:codex/generative-query-error

Conversation

@karthiksenv

@karthiksenv karthiksenv commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Generative-query failures currently raise the same WeaviateQueryError as ordinary searches, so applications cannot select RAG-specific troubleshooting by exception type.

Add WeaviateGenerativeQueryError as a subclass of WeaviateQueryError. Sync and async gRPC searches select it when the request contains the generative field, including deadline expiry and exhausted retries. A shared _search_error helper selects the exception in both clients. Permission errors are handled before that selection.

Compatibility: existing except WeaviateQueryError handlers and isinstance(e, WeaviateQueryError) checks still match. Exact checks such as type(e) is WeaviateQueryError no longer match failed generative requests; use isinstance when subclasses should match. The existing GRPC search error wording is preserved. The message and error attributes retain the original details, and exception chaining preserves the cause. Ordinary searches retain the generic exception.

The exception identifies a failed generative request; retrieval can also fail, so it does not assume the provider caused the failure. The exception documentation includes a catch-order example and troubleshooting guidance.

Closes #818.

Validation of the current commit (a22d4f3):

  • Four mock cases pass on Linux with Python 3.12.13: retry exhaustion and permission handling for sync and async clients.
  • Both integration tests pass against a temporary local Weaviate 1.39.7 server with generative-dummy,generative-anyscale enabled and no provider API key. They check the specialized generative exception, compatibility with the base exception and existing error wording, and the exact generic exception for ordinary queries.
  • Ruff checks and formatting checks pass for all four files changed by the review follow-up; git diff --check passes.

Before the review follow-up, the full Linux unit/mock suite passed with 646 tests passing and 1 skipped. That earlier run covered the previous commit, not the revised test suite.

@orca-security-eu orca-security-eu 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.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@karthiksenv
karthiksenv marked this pull request as ready for review October 17, 2026 22:20
@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@karthiksenv

Copy link
Copy Markdown
Contributor Author

I agree to the Weaviate Contributor License Agreement.

The Main CI workflow is awaiting maintainer approval. Could a maintainer approve the workflow and review this PR? The local Linux unit/mock suite passed with 646 tests passing and 1 skipped, and the before/after behavior was verified against Weaviate 1.39.7 for both sync and async clients.

@karthiksenv

Copy link
Copy Markdown
Contributor Author

@dirkkul, could you review this generative-query exception change or route it to the appropriate reviewer? The CLA acknowledgment and local validation are documented above. Please also confirm whether any fork CI approval or additional checks are needed before merge.

@karthiksenv

Copy link
Copy Markdown
Contributor Author

@dirkkul, could you review the generative-query exception contract or route it to the Python client reviewer? The new exception remains a subclass of WeaviateQueryError, preserving existing handlers. The CLA acknowledgment, 646-test Linux run, and real-server before/after checks are documented above. Could you also confirm whether the Main workflow still needs fork approval and what remains before merge?

Comment thread weaviate/exceptions.py Resolved
Comment thread weaviate/connect/v4.py Resolved
Comment thread mock_tests/test_generative_errors.py Resolved
@karthiksenv
karthiksenv requested a review from dirkkul November 11, 2026 23:11
@karthiksenv

Copy link
Copy Markdown
Contributor Author

Hi @dirkkul and @tsmith023, I’ve addressed the three review comments in a22d4f3 and added the compatibility note to the PR description.

The four mock cases pass, and both integration tests pass against Weaviate 1.39.7. Lint and formatting checks pass too.

Could you approve the pending CI workflow and take another look? If everything looks good and the required checks pass, I’d appreciate your approval and a merge. I’m happy to make any final adjustments. Thanks!

@dirkkul
dirkkul merged commit 3325b18 into weaviate:main Nov 12, 2026
126 of 129 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Create a specific set of exception messages for generative queries

3 participants