lance-format / lance-format/lance-data-viewer

feat: add Pydantic response models for all endpoints

Open
#41 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
60
Forks
9
Avg merge
10m
Merged PRs (30d)
4

Description

Right now all six endpoints return plain dict / JSONResponse objects constructed by hand in app.py. FastAPI can infer loose schemas from the return type hints but there is no enforced contract between the backend and the frontend, and the OpenAPI schema that FastAPI generates is correspondingly thin.

Adding Pydantic response models would:

  • Give the frontend a stable contract to rely on. Serialization drift between backend versions would fail in the route handler rather than silently returning a malformed shape to the UI.
  • Produce a much richer OpenAPI schema. This pairs naturally with #23, which covers exposing the Swagger UI at /docs.
  • Catch bugs at the boundary. If serialize_arrow_value returns something that does not match the declared shape, Pydantic raises a clear validation error instead of the frontend getting mystery fields.

No new dependencies: Pydantic is already a transitive dependency of FastAPI.

Sketch:

from pydantic import BaseModel

class HealthResponse(BaseModel):
    ok: bool
    app_version: str
    lancedb_version: str
    pyarrow_version: str
    build_tag: str | None = None
    compat: dict[str, bool]

@app.get("/healthz", response_model=HealthResponse)
async def healthz() -> HealthResponse:
    ...

Scope: one model per endpoint (six total), plus the nested shapes for /schema, /columns, and the vector cell object. Can be done in a single PR without touching any business logic, just the return types and response construction.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in app.py by locating the six endpoint handlers and their hand-built dict or JSONResponse results, beginning with the /healthz example. Trace the response shapes for each route, including the nested /schema, /columns, and vector cell objects, then verify that the generated OpenAPI schemas and handler responses match the declared models.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.