Skip to content

fix: resolve CI test failure and pages deployment error#14

Merged
OriNachum merged 3 commits into
mainfrom
fix/ci-and-pages-failures
Apr 2, 2026
Merged

fix: resolve CI test failure and pages deployment error#14
OriNachum merged 3 commits into
mainfrom
fix/ci-and-pages-failures

Conversation

@OriNachum

Copy link
Copy Markdown
Contributor

Summary

  • CI tests: KnowledgeBaseIntegrationService.__init__ now catches KB service init failures gracefully (sets kb_service = None) instead of crashing with ConfigurationError when AWS_REGION is unset. This fixes test_chat_completion_openai_format returning 500 in CI.
  • Pages deployment: Regenerated docs/Gemfile.lock so its DEPENDENCIES section matches the Gemfile's just-the-docs (~> 0.12) constraint (was ~> 0.10), fixing the frozen-mode bundle install failure.

Test plan

  • uv run pytest -m "unit" -v — 26 passed
  • uv run pytest -m "integration and not real_api" -v — 4 passed, 1 skipped (previously 1 failed)
  • CI workflows pass on this PR

🤖 Generated with Claude Code

  • Claude

Make KB service initialization graceful so chat completions work without
AWS credentials. Regenerate docs/Gemfile.lock to match Gemfile's
just-the-docs ~> 0.12 constraint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 2, 2026 21:56
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Fix CI test failures and pages deployment errors

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• KB service initialization now gracefully handles missing AWS credentials
  - Catches exceptions and sets kb_service = None instead of crashing
  - Prevents 500 errors in chat completion endpoints during CI tests
• Added null check for kb_service in RAG decision logic
• Regenerated docs/Gemfile.lock to match just-the-docs ~> 0.12 constraint
Diagram
flowchart LR
  A["KB Service Init"] -->|Exception Caught| B["Log Warning"]
  B --> C["Set kb_service = None"]
  C --> D["Chat Completion Works"]
  E["RAG Decision Logic"] -->|Check kb_service| F["Graceful Fallback"]
  G["Gemfile.lock"] -->|Regenerated| H["Match Gemfile Constraint"]
Loading

Grey Divider

File Changes

1. src/open_bedrock_server/services/knowledge_base_integration_service.py 🐞 Bug fix +6/-2

Add graceful KB service initialization error handling

• Wrapped get_knowledge_base_service() call in try-except block to gracefully handle
 initialization failures
• Logs warning and sets kb_service = None when service initialization fails
• Added null check for self.kb_service in should_use_direct_rag() method to prevent errors when
 KB service is unavailable

src/open_bedrock_server/services/knowledge_base_integration_service.py


2. docs/Gemfile.lock ⚙️ Configuration changes +0/-0

Regenerate Gemfile.lock for just-the-docs version

• Regenerated lock file to match Gemfile's just-the-docs (~> 0.12) dependency constraint
• Updates DEPENDENCIES section to reflect correct version specification
• Fixes frozen-mode bundle install failure in pages deployment

docs/Gemfile.lock


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Apr 2, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX Issues (0)

Grey Divider


Remediation recommended

1. KB None triggers exceptions🐞 Bug ☼ Reliability
Description
When __init__ sets self.kb_service=None, enhance_chat_request() can still call
self.kb_service.retrieve(...), raising AttributeError and falling into the generic exception handler
(logging an error and skipping KB augmentation). This will cause repeated exception-driven flow and
noisy error logs in environments where KB init fails but requests still trigger KB detection.
Code

src/open_bedrock_server/services/knowledge_base_integration_service.py[R34-38]

+        try:
+            self.kb_service = get_knowledge_base_service()
+        except Exception as e:
+            logger.warning(f"Knowledge Base service unavailable: {e}")
+            self.kb_service = None
Evidence
The PR change explicitly sets kb_service to None on initialization failure; enhance_chat_request()
later calls self.kb_service.retrieve(...) without a None guard, and will then hit its broad
exception handler (logger.error + return original request). The main chat route always instantiates
this integration service and calls enhance_chat_request() regardless of whether direct RAG was used,
so this path can be exercised frequently when KB is unavailable.

src/open_bedrock_server/services/knowledge_base_integration_service.py[33-39]
src/open_bedrock_server/services/knowledge_base_integration_service.py[56-114]
src/open_bedrock_server/api/routes/chat.py[213-257]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`KnowledgeBaseIntegrationService` now allows `self.kb_service` to be `None`, but `enhance_chat_request()` still calls `self.kb_service.retrieve(...)` unconditionally once KB usage is detected. This leads to `AttributeError` (caught later), causing exception-driven control flow and error logs when KB is simply unavailable.

## Issue Context
Direct RAG is guarded via `should_use_direct_rag()` now checking `not self.kb_service`, but the fallback path still calls `enhance_chat_request()` and can attempt retrieval.

## Fix Focus Areas
- src/open_bedrock_server/services/knowledge_base_integration_service.py[41-115]

## Suggested fix
- Add an early return in `enhance_chat_request()` when `self.kb_service is None` (ideally after computing `should_use_kb` / `kb_id`, or even earlier), e.g.:
 - if KB would be used but service is unavailable: log at `debug`/`warning` once and return the original request.
- Optionally add a similar guard in `process_rag_request()` for defense-in-depth (raise a `ServiceUnavailableError` or fall back cleanly).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Advisory comments

2. Init warning lacks traceback🐞 Bug ✧ Quality
Description
The __init__ handler logs only the exception message when KB service initialization fails, which
makes diagnosing deployment/config failures harder. Without the stack trace, root-causing
intermittent boto/session/client init issues is significantly more difficult.
Code

src/open_bedrock_server/services/knowledge_base_integration_service.py[R36-37]

+        except Exception as e:
+            logger.warning(f"Knowledge Base service unavailable: {e}")
Evidence
On KB init failure, the code logs a warning with the exception string only and does not include
exc_info=True, so the traceback is dropped.

src/open_bedrock_server/services/knowledge_base_integration_service.py[33-38]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Initialization failure logging drops the traceback, reducing debuggability.

## Issue Context
`logger.warning(f"Knowledge Base service unavailable: {e}")` only logs the exception message.

## Fix Focus Areas
- src/open_bedrock_server/services/knowledge_base_integration_service.py[33-38]

## Suggested fix
- Switch to structured logging with traceback, e.g.:
 - `logger.warning("Knowledge Base service unavailable", exc_info=True)`
 - or `logger.exception(...)` if appropriate (note: `logger.exception` logs at ERROR by default).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses CI instability in the chat completions endpoint by making Knowledge Base integration initialization non-fatal when AWS configuration is missing, and fixes GitHub Pages deployment by aligning the docs lockfile dependency constraint with the Gemfile.

Changes:

  • Make KnowledgeBaseIntegrationService tolerate Knowledge Base service initialization failures by falling back to kb_service = None.
  • Prevent direct RAG selection when the KB service is unavailable.
  • Update docs/Gemfile.lock to match the Gemfile’s just-the-docs (~> 0.12) constraint.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/open_bedrock_server/services/knowledge_base_integration_service.py Adds graceful KB service init fallback and avoids direct RAG when KB is unavailable.
docs/Gemfile.lock Updates dependency constraint to just-the-docs (~> 0.12) for bundler frozen-mode compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

OriNachum and others added 2 commits April 3, 2026 01:00
This class asserts that API keys are configured, which can't pass
without credentials. Was causing all-safe test step to fail in CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback:
- Catch ConfigurationError instead of broad Exception with exc_info=True
- Add early return in enhance_chat_request when kb_service is None

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@OriNachum OriNachum merged commit 2ecfb1c into main Apr 2, 2026
4 checks passed
@OriNachum OriNachum deleted the fix/ci-and-pages-failures branch April 2, 2026 22:05
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.

2 participants