Skip to content

LCORE-1955: Fixed issues in BYOK integration tests#1559

Merged
tisnik merged 1 commit into
lightspeed-core:mainfrom
tisnik:lcore-1955-fixed-issues-in-byok-integration-tests
Apr 21, 2026
Merged

LCORE-1955: Fixed issues in BYOK integration tests#1559
tisnik merged 1 commit into
lightspeed-core:mainfrom
tisnik:lcore-1955-fixed-issues-in-byok-integration-tests

Conversation

@tisnik
Copy link
Copy Markdown
Contributor

@tisnik tisnik commented Apr 21, 2026

Description

LCORE-1955: Fixed issues in BYOK integration tests

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
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-1955

Summary by CodeRabbit

  • Tests
    • Improved test consistency and coverage for query request parameter handling across integration test scenarios.

Note: This release contains no user-facing changes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Walkthrough

Test code in the BYOK query integration suite was refactored to explicitly pass all QueryRequest constructor parameters (such as conversation_id, provider, model, system_prompt, attachments, no_tools, generate_topic_summary, media_type, vector_store_ids, shield_ids, and solr) instead of relying on default values across multiple test scenarios.

Changes

Cohort / File(s) Summary
Query Integration Tests
tests/integration/endpoints/test_query_byok_integration.py
Updated all QueryRequest instantiations to explicitly define optional parameters (conversation_id, provider, model, system_prompt, attachments, no_tools, generate_topic_summary, media_type, vector_store_ids, shield_ids, solr) across inline RAG, tool RAG, combined RAG, vector store filtering, and error handling test cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly relates to the main change: updating BYOK integration tests by explicitly passing request fields to QueryRequest constructors.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integration/endpoints/test_query_byok_integration.py`:
- Around line 325-338: Tests are overly verbose because each QueryRequest is
constructed with all parameters instead of using defaults; update tests to only
pass relevant fields (e.g., query and when needed vector_store_ids) by removing
redundant arguments from QueryRequest calls, or add a small test factory like
make_query_request(query, vector_store_ids=None, **overrides) and use it across
tests; locate constructions of QueryRequest in test_query_byok_integration.py
(e.g., the query_request variable instances) and replace them with minimal calls
or the factory to reduce duplication and improve clarity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 97f60739-ef7f-49d0-8179-7350ede60228

📥 Commits

Reviewing files that changed from the base of the PR and between 303fbe3 and 39eca36.

📒 Files selected for processing (1)
  • tests/integration/endpoints/test_query_byok_integration.py
📜 Review details
⏰ 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). (15)
  • GitHub Check: mypy
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: build-pr
  • GitHub Check: Pylinter
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Import FastAPI dependencies with: from fastapi import APIRouter, HTTPException, Request, status, Depends
Import Llama Stack client with: from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
Type aliases defined at module level for clarity
Use Final[type] as type hint for all constants
All functions require docstrings with brief descriptions
Complete type annotations for parameters and return types in functions
Use typing_extensions.Self for model validators in Pydantic models
Use modern union type syntax str | int instead of Union[str, int]
Use Optional[Type] for optional type hints
Use snake_case with descriptive, action-oriented function names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead
Use async def for I/O operations and external API calls
Handle APIConnectionError from Llama Stack in error handling
Use standard log levels with clear purposes: debug, info, warning, error
All classes require descriptive docstrings explaining purpose
Use PascalCase for class names with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Use ABC for abstract base classes with @abstractmethod decorators
Use @model_validator and @field_validator for Pydantic model validation
Complete type annotations for all class attributes; use specific types, not Any
Follow Google Python docstring conventions with Parameters, Returns, Raises, and Attributes sections

Files:

  • tests/integration/endpoints/test_query_byok_integration.py
tests/{unit,integration}/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest; pytest is the standard for this project
Use pytest-mock for AsyncMock objects in tests
Use marker pytest.mark.asyncio for async tests
Unit tests require 60% coverage, integration tests 10%

Files:

  • tests/integration/endpoints/test_query_byok_integration.py
🧠 Learnings (1)
📚 Learning: 2026-02-23T14:11:46.950Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1198
File: src/utils/responses.py:184-188
Timestamp: 2026-02-23T14:11:46.950Z
Learning: The query request validator in the Responses API flow requires that `query_request.model` and `query_request.provider` must either both be specified or both be absent. The concatenated format (e.g., `model="provider/model"` with `provider=None`) is not permitted by the validator.

Applied to files:

  • tests/integration/endpoints/test_query_byok_integration.py

Comment on lines +325 to +338
query_request = QueryRequest(
query="What is OpenShift?",
conversation_id=None,
provider=None,
model=None,
system_prompt=None,
attachments=None,
no_tools=False,
generate_topic_summary=None,
media_type=None,
vector_store_ids=None,
shield_ids=None,
solr=None,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Reduce test verbosity by leveraging QueryRequest defaults or introducing a test helper.

All 13 test cases now explicitly pass every QueryRequest parameter, even when most are set to their default values. This creates significant code duplication (~150 lines of repetitive parameter assignments) and obscures test intent by burying the meaningful parameters (query and occasionally vector_store_ids) among boilerplate.

Testing best practice is to specify only parameters relevant to each test, allowing the model's defaults to handle the rest. This improves maintainability and makes each test's purpose clearer.

♻️ Recommended approaches

Option 1 (Preferred): Rely on QueryRequest defaults

Most parameters can be omitted entirely:

 query_request = QueryRequest(
     query="What is OpenShift?",
-    conversation_id=None,
-    provider=None,
-    model=None,
-    system_prompt=None,
-    attachments=None,
-    no_tools=False,
-    generate_topic_summary=None,
-    media_type=None,
-    vector_store_ids=None,
-    shield_ids=None,
-    solr=None,
 )

For tests that need specific vector_store_ids:

 query_request = QueryRequest(
     query="What is OpenShift?",
-    conversation_id=None,
-    provider=None,
-    model=None,
-    system_prompt=None,
-    attachments=None,
-    no_tools=False,
-    generate_topic_summary=None,
-    media_type=None,
     vector_store_ids=["source-a"],
-    shield_ids=None,
-    solr=None,
 )

Option 2: Introduce a test helper factory

If explicit control is needed across all tests, create a helper function in the test file:

def make_query_request(
    query: str,
    vector_store_ids: list[str] | None = None,
    **overrides: Any,
) -> QueryRequest:
    """Build a QueryRequest with common test defaults."""
    return QueryRequest(
        query=query,
        conversation_id=overrides.get("conversation_id"),
        provider=overrides.get("provider"),
        model=overrides.get("model"),
        system_prompt=overrides.get("system_prompt"),
        attachments=overrides.get("attachments"),
        no_tools=overrides.get("no_tools", False),
        generate_topic_summary=overrides.get("generate_topic_summary"),
        media_type=overrides.get("media_type"),
        vector_store_ids=vector_store_ids,
        shield_ids=overrides.get("shield_ids"),
        solr=overrides.get("solr"),
    )

Then use it:

query_request = make_query_request("What is OpenShift?")
# Or with filtering:
query_request = make_query_request("What is OpenShift?", vector_store_ids=["source-a"])

Also applies to: 385-398, 471-484, 542-555, 593-606, 637-650, 685-698, 728-741, 849-862, 930-943, 1033-1046, 1118-1131, 1222-1235

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/endpoints/test_query_byok_integration.py` around lines 325
- 338, Tests are overly verbose because each QueryRequest is constructed with
all parameters instead of using defaults; update tests to only pass relevant
fields (e.g., query and when needed vector_store_ids) by removing redundant
arguments from QueryRequest calls, or add a small test factory like
make_query_request(query, vector_store_ids=None, **overrides) and use it across
tests; locate constructions of QueryRequest in test_query_byok_integration.py
(e.g., the query_request variable instances) and replace them with minimal calls
or the factory to reduce duplication and improve clarity.

@tisnik tisnik merged commit ca47172 into lightspeed-core:main Apr 21, 2026
30 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.

1 participant