Skip to content

docs: add exception reference and error handling guide#654

Open
TheSaiEaranti wants to merge 1 commit into
redis:mainfrom
TheSaiEaranti:docs-exception-reference
Open

docs: add exception reference and error handling guide#654
TheSaiEaranti wants to merge 1 commit into
redis:mainfrom
TheSaiEaranti:docs-exception-reference

Conversation

@TheSaiEaranti

@TheSaiEaranti TheSaiEaranti commented Jul 25, 2026

Copy link
Copy Markdown

Fixes #496

Adds docs/api/exceptions.rst and links it from the API toctree, so the exception hierarchy has one discoverable home.

What's on the page

  • The hierarchy — all five classes in redisvl.exceptions, and a note that redis-py exceptions such as redis.exceptions.ConnectionError are not part of it. RedisVL wraps those and chains the original with raise ... from e, so __cause__ still holds it. That seemed like the detail most likely to trip someone writing an except clause.
  • A table mapping each exception to the operations that raise it, e.g. SchemaValidationErrorload(), RedisSearchErrorcreate() / delete() / search() / aggregate().
  • Four try/except examples, including the two the issue asks for.
  • Autodoc reference for each class, following the :members: / :show-inheritance: pattern used in schema.rst.

Examples are drawn from real raise sites

Rather than writing plausible-looking snippets, I traced each exception to where it is actually raised so the examples match current behaviour:

Exception Verified raise site What the example shows
SchemaValidationError storage.py _preprocess_and_validate_objects validate_on_load=True, since validation is off by default and the error cannot otherwise occur
QueryValidationError index.py _validate_query ef_runtime on a flat vector field — the concrete case that method rejects
RedisSearchError create, delete, search, aggregate wrapping a Redis-side failure
RedisModuleVersionError _check_svs_support, reached from create() ordering except clauses, since it subclasses RedisVLError and not RedisSearchError

The from_yaml(..., validate_on_load=True) form matches the example already in the SearchIndex docstring.

Definition of Done

  • Exception docs present and discoverabledocs/_build/html/api/exceptions.html renders, all five classes appear with their docstrings, RedisModuleVersionError.for_svs_vamana is documented, and the page is linked from the API index as "Exceptions".
  • make docs-build passes — exit 0. The build reports 11 warnings; all 11 are pre-existing and point at query.py / aggregate.py docstrings inherited from redis-py, index.md heading levels, and the MCP how-to cross-references. None reference exceptions.rst.
  • Examples align with current exception classes — per the table above.

codespell is clean on both files. No Python changed, so no behaviour change.

Notes

  • Docs-only, so this needs the auto:documentation label per CONTRIBUTING. I can't set labels as an outside contributor — could a maintainer add it?
  • I deliberately left uv.lock out. Running make docs-build with a recent uv rewrites it to lockfile revision 3 (a ~250 line diff) which has nothing to do with this change.
  • If docs: migrate from Sphinx to mkdocs material #608 (Sphinx → mkdocs) lands first, this page is a single autodoc file and cheap to port; happy to do that conversion if you'd prefer to wait for it.

Note

Low Risk
Documentation-only change with no runtime or API behavior impact.

Overview
Adds docs/api/exceptions.rst as the API home for RedisVL’s custom errors and wires it into the API toctree via docs/api/index.md.

The new page documents the RedisVLError hierarchy (including how redis-py errors are wrapped and chained on __cause__), a table mapping each exception to typical load() / query() / create() entry points, four try/except examples aligned with real raise sites, and autodoc blocks for all five classes in redisvl.exceptions.

Reviewed by Cursor Bugbot for commit 55cf1a2. Bugbot is set up for automated code reviews on this repo. Configure here.

Add docs/api/exceptions.rst and link it from the API toctree, so the exception
hierarchy is documented in one discoverable place.

The page covers the five classes in redisvl.exceptions, a table mapping each to
the operations that raise it, and try/except examples for the two cases called
out in the issue: schema validation on load and query validation. Each example
is drawn from an actual raise site, so validate_on_load=True is shown for
SchemaValidationError and ef_runtime on a flat vector field for
QueryValidationError.

Also notes that redis-py exceptions are not part of the hierarchy and that
RedisVL chains the original error, since that is the part most likely to trip
someone writing an except clause.

Fixes redis#496
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.

Document RedisVL exception hierarchy and error handling patterns

1 participant