Repository navigation
[BUG](frontend): Correct OpenAPI response models for list databases and collections - #8005
Open
Abdulrehman1978 wants to merge 1 commit into
Open
Abdulrehman1978 wants to merge 1 commit into
Abdulrehman1978 wants to merge 1 commit into
Conversation
…nd collections Fixes chroma-core#7933 When �ody = ListDatabasesResponse and �ody = ListCollectionsResponse were passed to utoipa's #[utoipa::path] attribute, utoipa did not resolve the type aliases (Vec<Database> and Vec<Collection>) at macro expansion time. Instead, it invoked ToSchema::schema() at runtime, registering a schema component named "Vec" in OpenAPI. Whichever endpoint was registered last overwrote #/components/schemas/Vec (in this case Collection), causing GET /api/v2/tenants/{tenant}/databases to declare its response as #/components/schemas/Vec containing Collection schema fields. This change: - Uses �ody = Vec<Database> for list_databases so OpenAPI emits an array schema with items $ref: #/components/schemas/Database. - Uses �ody = Vec<Collection> for list_collections so OpenAPI emits an array schema with items $ref: #/components/schemas/Collection. - Updates the Hey API generated types in clients/new-js to type ListDatabasesResponses and ListCollectionsResponses as Array<Database> and Array<Collection>. - Adds a unit test est_list_databases_and_collections_openapi_schema verifying the OpenAPI document generates the expected array references and no longer contains a Vec schema component.
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7933
Description of changes
In
rust/frontend/src/server.rs,GET /api/v2/tenants/{tenant}/databasesandGET /api/v2/tenants/{tenant}/databases/{database}/collectionspreviously used the type aliasesListDatabasesResponseandListCollectionsResponseinresponses(...)(body = ListDatabasesResponseandbody = ListCollectionsResponse).Because utoipa proc-macros operate on syntax tokens without expanding type aliases, utoipa did not know
ListDatabasesResponseandListCollectionsResponsewereVec<Database>andVec<Collection>. At runtime, utoipa registered a component schema named"Vec"in OpenAPI. Becauselist_collectionswas registered afterlist_databases, the"Vec"schema component was overwritten with the schema ofCollection(requiringid,name,configuration_json,tenant,database,log_position,version). As a result,GET /api/v2/tenants/{tenant}/databasesdeclared its response as#/components/schemas/Vecwhich failed OpenAPI client validation against actual database objects[{"id": "...", "name": "...", "tenant": "..."}].This PR:
body = ListDatabasesResponsewithbody = Vec<Database>inrust/frontend/src/server.rs.body = ListCollectionsResponsewithbody = Vec<Collection>inrust/frontend/src/server.rs.clients/new-js/packages/chromadb/src/api/types.gen.tsto type responses asArray<Database>andArray<Collection>, eliminating the phantomVectype.test_list_databases_and_collections_openapi_schemato verify both endpoints declare arrays referencingDatabaseandCollectionand that no"Vec"schema component is generated.Test plan
cargo test --package chroma-frontend --lib test_list_databases_and_collections_openapi_schema:cargo check --libpasses inrust/frontend.Migration plan
None. This is backward-compatible and fixes OpenAPI schema validation for API clients.
Observability plan
Existing metrics and tracing remain unchanged.
Documentation Changes
No user-facing API documentation changes needed; OpenAPI schema now accurately reflects the endpoint response.