Skip to content

Conversation

tisnik
Copy link
Contributor

@tisnik tisnik commented Aug 31, 2025

Description

LCORE-466: Llama Stack version in /info endpoint

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

  • Related Issue #LCORE-466

Summary by CodeRabbit

  • New Features

    • Info endpoint now returns both service_version and llama_stack_version.
    • Returns a clear 500 error when the service cannot connect to the external stack.
  • Refactor

    • Renamed response field version to service_version and updated response schema and docs.
  • Tests

    • Added unit tests for successful version retrieval and connection-failure handling.

Copy link
Contributor

coderabbitai bot commented Aug 31, 2025

Warning

Rate limit exceeded

@tisnik has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1a35054 and 08a4934.

📒 Files selected for processing (4)
  • docs/openapi.json (2 hunks)
  • docs/openapi.md (2 hunks)
  • docs/output.md (2 hunks)
  • src/app/endpoints/info.py (3 hunks)

Walkthrough

The /info endpoint now obtains a Llama Stack client and fetches its version asynchronously, updates the response schema to include service_version and llama_stack_version, adds error handling for connection failures (raising HTTP 500), and updates docs and unit tests to match the new model and behavior.

Changes

Cohort / File(s) Summary
Endpoint behavior & error handling
src/app/endpoints/info.py
Replaces static response with async acquisition of AsyncLlamaStackClientHolder and call to client.inspect.version(). Returns InfoResponse(name, service_version, llama_stack_version). Catches APIConnectionError, logs, and raises HTTPException 500 with detail.
Response model & docs
src/models/responses.py, docs/openapi.json, docs/openapi.md, docs/output.md
InfoResponse.version renamed to service_version; added llama_stack_version. Updated docstrings, OpenAPI schema, examples, and documentation tables to reflect new required fields.
Tests
tests/unit/app/endpoints/test_info.py
Updated success-path test to mock client and assert service_version present and llama_stack_version == "0.1.2". Added failure-path test where APIConnectionError causes endpoint to raise HTTPException 500. Patches configuration and client getter for isolation.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant API as /info Endpoint
  participant Holder as AsyncLlamaStackClientHolder
  participant LSC as Llama Stack Client

  User->>API: GET /info
  activate API
  API->>Holder: acquire client (async)
  Holder-->>API: client
  API->>LSC: client.inspect.version() (async)
  alt success
    LSC-->>API: VersionInfo(version)
    API-->>User: 200 OK { name, service_version, llama_stack_version }
  else APIConnectionError
    LSC-->>API: APIConnectionError
    API-->>User: 500 { detail: "Unable to connect to Llama Stack", response, cause }
  end
  deactivate API
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

In burrows of code I hop and dash,
I sniff the stack, I fetch the hash.
Service sings its version bright,
Stack replies — then logs the night.
If wires fray, I thump: "500!" — dash! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tisnik tisnik force-pushed the lcore-466-llama-stack-version-in-info-endpoint branch from 4f4b6e4 to 9e60ab4 Compare August 31, 2025 11:37
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
docs/openapi.md (1)

36-41: Update /v1/info docs to reflect new fields and add 500 error.

The text still says “name and version” and the responses table lacks the documented 500 on Llama connection failures. Update both to avoid drift with implementation/tests.

-Process GET requests to the /info endpoint, returning the
-service name and version.
+Process GET requests to the /info endpoint, returning the
+service name, service version, and Llama Stack version.

-Returns:
-    InfoResponse: An object containing the service's name and version.
+Returns:
+    InfoResponse: An object containing the service's name, service_version, and llama_stack_version.
 | 200 | Successful Response | [InfoResponse](#inforesponse) |
+| 500 | Unable to connect to Llama Stack | [ErrorResponse](#errorresponse) |

Also applies to: 48-50

docs/openapi.json (1)

53-68: Fix /v1/info OpenAPI: stale description, invalid extra keys, and missing 500 response.

  • Description still mentions just “name and version”.
  • The 200 response incorrectly includes top-level “name” and “version” alongside content, which is invalid OpenAPI and also stale.
  • Missing 500 response matching the endpoint behavior.
-                "description": "Handle request to the /info endpoint.\n\nProcess GET requests to the /info endpoint, returning the\nservice name and version.\n\nReturns:\n    InfoResponse: An object containing the service's name and version.",
+                "description": "Handle request to the /info endpoint.\n\nProcess GET requests to the /info endpoint, returning the service name, service version, and Llama Stack version.\n\nReturns:\n    InfoResponse: An object containing the service's name, service_version, and llama_stack_version.",
                 "operationId": "info_endpoint_handler_v1_info_get",
                 "responses": {
                     "200": {
                         "description": "Successful Response",
                         "content": {
                             "application/json": {
                                 "schema": {
                                     "$ref": "#/components/schemas/InfoResponse"
-                                }
+                                },
+                                "example": {
+                                    "name": "Lightspeed Stack",
+                                    "service_version": "1.0.0",
+                                    "llama_stack_version": "0.2.18"
+                                }
                             }
-                        },
-                        "name": "Service name",
-                        "version": "Service version"
+                        }
+                    },
+                    "500": {
+                        "description": "Unable to connect to Llama Stack",
+                        "content": {
+                            "application/json": {
+                                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
+                                "example": {
+                                    "detail": {
+                                        "response": "Unable to connect to Llama Stack",
+                                        "cause": "Connection error."
+                                    }
+                                }
+                            }
+                        }
                     }
                 }
docs/output.md (1)

36-41: Align /v1/info narrative and responses with implementation.

Same drift as openapi.md: mention service_version and llama_stack_version, and document 500 response.

-Process GET requests to the /info endpoint, returning the
-service name and version.
+Process GET requests to the /info endpoint, returning the
+service name, service version, and Llama Stack version.

-Returns:
-    InfoResponse: An object containing the service's name and version.
+Returns:
+    InfoResponse: An object containing the service's name, service_version, and llama_stack_version.
 | 200 | Successful Response | [InfoResponse](#inforesponse) |
+| 500 | Unable to connect to Llama Stack | [ErrorResponse](#errorresponse) |

Also applies to: 48-50

🧹 Nitpick comments (4)
docs/openapi.json (1)

1609-1637: LGTM on InfoResponse schema; tiny nit on example value.

Schema changes are correct. Nit: consider using a realistic Llama Stack semver (e.g., “0.2.18”) in examples for consistency with docs.

Also applies to: 1638-1643

tests/unit/app/endpoints/test_info.py (3)

56-56: Remove duplicate mock_authorization_resolvers call.

It’s already invoked on Line 17; the second call is redundant.

-    mock_authorization_resolvers(mocker)

50-52: Unnecessary patching of app.endpoints.models.configuration.

The handler reads from configuration.configuration; this patch is unused noise. Safe to remove in both tests.

-    mock_config = mocker.Mock()
-    mocker.patch("app.endpoints.models.configuration", mock_config)

Also applies to: 107-109


19-41: DRY the repeated test config via a fixture.

Extract the shared config_dict/AppConfig init into a pytest fixture to reduce duplication and ease maintenance.

Also applies to: 77-98

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f4b6e4 and 1a35054.

📒 Files selected for processing (5)
  • docs/openapi.json (1 hunks)
  • docs/openapi.md (1 hunks)
  • docs/output.md (1 hunks)
  • src/app/endpoints/info.py (2 hunks)
  • tests/unit/app/endpoints/test_info.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/endpoints/info.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/unit/app/endpoints/test_info.py (3)
tests/unit/utils/auth_helpers.py (1)
  • mock_authorization_resolvers (9-27)
src/configuration.py (2)
  • AppConfig (32-135)
  • init_from_dict (55-57)
src/app/endpoints/info.py (1)
  • info_endpoint_handler (35-74)
🪛 LanguageTool
docs/openapi.md

[grammar] ~898-~898: There might be a mistake here.
Context: ... ``` | Field | Type | Description | |-------|------|-------------| | name | ...

(QB_NEW_EN)


[grammar] ~899-~899: There might be a mistake here.
Context: ...ription | |-------|------|-------------| | name | string | Service name | | servi...

(QB_NEW_EN)


[grammar] ~900-~900: There might be a mistake here.
Context: ...------| | name | string | Service name | | service_version | string | Service ver...

(QB_NEW_EN)


[grammar] ~901-~901: There might be a mistake here.
Context: ...ice_version | string | Service version | | llama_stack_version | string | Llama S...

(QB_NEW_EN)

docs/output.md

[grammar] ~888-~888: There might be a mistake here.
Context: ... ``` | Field | Type | Description | |-------|------|-------------| | name | ...

(QB_NEW_EN)


[grammar] ~889-~889: There might be a mistake here.
Context: ...ription | |-------|------|-------------| | name | string | Service name | | servi...

(QB_NEW_EN)


[grammar] ~890-~890: There might be a mistake here.
Context: ...------| | name | string | Service name | | service_version | string | Service ver...

(QB_NEW_EN)


[grammar] ~891-~891: There might be a mistake here.
Context: ...ice_version | string | Service version | | llama_stack_version | string | Llama S...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-pr
  • GitHub Check: e2e_tests
🔇 Additional comments (2)
docs/openapi.md (1)

885-894: LGTM: InfoResponse fields renamed/added correctly.

The switch to service_version and addition of llama_stack_version look consistent with code.

Also applies to: 898-903

docs/output.md (1)

875-884: LGTM: InfoResponse docs updated correctly.

Fields and example align with the model and tests.

Also applies to: 888-893

Comment on lines +122 to +125
with pytest.raises(HTTPException) as e:
await info_endpoint_handler(auth=auth, request=request)
assert e.value.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
assert e.detail["response"] == "Unable to connect to Llama Stack"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Bug: exception assertion uses e.detail instead of e.value.detail.

This will fail; ExceptionInfo stores the exception on .value.

 with pytest.raises(HTTPException) as e:
     await info_endpoint_handler(auth=auth, request=request)
     assert e.value.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
-    assert e.detail["response"] == "Unable to connect to Llama Stack"
+    assert e.value.detail["response"] == "Unable to connect to Llama Stack"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with pytest.raises(HTTPException) as e:
await info_endpoint_handler(auth=auth, request=request)
assert e.value.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
assert e.detail["response"] == "Unable to connect to Llama Stack"
with pytest.raises(HTTPException) as e:
await info_endpoint_handler(auth=auth, request=request)
assert e.value.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
assert e.value.detail["response"] == "Unable to connect to Llama Stack"
🤖 Prompt for AI Agents
In tests/unit/app/endpoints/test_info.py around lines 122 to 125, the test uses
e.detail but ExceptionInfo stores the caught exception on .value; update the
assertions to access the exception via e.value (e.g., e.value.detail) so both
assertions reference e.value (keep the pytest.raises structure and existing
awaits as-is).

@tisnik tisnik force-pushed the lcore-466-llama-stack-version-in-info-endpoint branch from 1a35054 to 08a4934 Compare August 31, 2025 12:09
@tisnik tisnik merged commit d05946b into lightspeed-core:main Aug 31, 2025
19 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 18, 2025
18 tasks
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.

1 participant