Skip to content

Model Config: relax model validation to warning#902

Merged
Prajna1999 merged 4 commits into
mainfrom
chore/model-validation-warning
Jun 1, 2026
Merged

Model Config: relax model validation to warning#902
Prajna1999 merged 4 commits into
mainfrom
chore/model-validation-warning

Conversation

@vprashrex
Copy link
Copy Markdown
Collaborator

@vprashrex vprashrex commented Jun 1, 2026

Target issue is #901

Summary

validate_blob_model_or_raise no longer blocks requests when a model is missing from model_config or has a mismatched completion type. It logs a warning and lets the call through. Provider API stays the source of truth; model_config is now metadata, not a gatekeeper.

What changed

  • Model not found → logger.warning, continue.
  • Wrong completion type check removed entirely (no warning, no validation).
  • TTS voice check guarded against None model_row.
  • Missing model param still returns 400.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Summary by CodeRabbit

Bug Fixes

  • Model configuration validation improved to handle missing or unsupported models more gracefully, logging warnings instead of blocking operations and preventing continued processing.
  • TTS voice validation enhanced to accept unsupported voices while logging warnings for monitoring and tracking purposes.
  • STT model handling improved to properly support text-based completion types and related configurations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Model validation in validate_blob_model_or_raise now logs warnings for missing ModelConfig rows and unsupported TTS voices and continues processing; tests are updated to expect warnings and allow validation to proceed instead of asserting HTTP 400 errors.

Changes

Model validation: fail-fast to warning-and-continue

Layer / File(s) Summary
Core validation logic: warning instead of exception
backend/app/crud/model_config.py
logger is positioned after imports. validate_blob_model_or_raise logs a warning and continues when the (provider, model) ModelConfig row is missing, skips model-specific checks in that case, and logs a warning (instead of raising) for unsupported TTS voice values.
Test expectations: warnings logged instead of exceptions raised
backend/app/tests/crud/test_model_config.py
Tests now assert that missing models, mismatched completion types, and invalid TTS voices log warnings and allow validation to proceed. A new test verifies STT-only models are accepted when completion_type is text.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • AkhileshNegi
  • Prajna1999

Poem

🐰 I sniffed the logs and gave a cheer,
A gentle warning — no more fear.
Models wander through the flow,
Voices whisper, soft and low.
Validation hops along, light and clear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: model validation is being relaxed from fail-fast exceptions to warnings.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/model-validation-warning

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.

f"Voice '{voice}' is not supported for provider='{provider}' "
f"model='{model_name}'. Allowed: {allowed_voices}"
),
logger.warning(
Copy link
Copy Markdown
Collaborator Author

@vprashrex vprashrex Jun 1, 2026

Choose a reason for hiding this comment

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

@Prajna1999 Voice name validation is also being skipped now, only logging a warning instead of failing the request. Is this behavior okay?
Since if the voice is not allowed then provider itself will fail it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay lets keep this behaviour. Helpful for 11labs that allows passing custom voice ids and user generated ids should be allowed at Kaapi.

@vprashrex vprashrex self-assigned this Jun 1, 2026
@vprashrex vprashrex removed this from Kaapi-dev Jun 1, 2026
@vprashrex vprashrex linked an issue Jun 1, 2026 that may be closed by this pull request
@sentry
Copy link
Copy Markdown

sentry Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@Prajna1999 Prajna1999 left a comment

Choose a reason for hiding this comment

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

I think modality specific checks i.e text, stt, tts and their models should be mandatory, let's keep in mind to add that in the next task.

f"Voice '{voice}' is not supported for provider='{provider}' "
f"model='{model_name}'. Allowed: {allowed_voices}"
),
logger.warning(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay lets keep this behaviour. Helpful for 11labs that allows passing custom voice ids and user generated ids should be allowed at Kaapi.

f"type='{completion_type}'. Allowed: {allowed}"
),
logger.warning(
f"[validate_blob_model_or_raise] Model '{model_name}' not found for provider='{provider}'."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can add another line like Ignoring validation checks to provider, non-blocking.. Something that says although kaapi does not yet support this model, but passing thru as long as there are no typos/deprecated model in the model field.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah I added it .. but this is just the log, will helpful for devs only. not for the client .. for client can we send the message in webhook callback ?

{
    "success": true,
    "data": {
        "job_id": "1170d050-2901-4511-97d4-40784d338405",
        "status": "SUCCESS",
        "llm_response": {
            "response": {
                "provider_response_id": "WiIdaoSoFfmfjuMPicKmqAQ",
                "conversation_id": null,
                "provider": "google",
                "model": "gemini-2.5-pro",
                "output": {
                    "type": "text",
                    "content": {
                        "format": "text",
                        "value": "Output"
                    }
                }
            },
            "usage": {
                "input_tokens": 12,
                "output_tokens": 120,
                "total_tokens": 1359,
                "reasoning_tokens": 1227
            },
            "provider_raw_response": null
        },
        "error_message": null
    },
    "error": null,
    "errors": null,
    "metadata": {"message": "Kaapi does not yet support this model, but will forward as long as the `model` field has no typos and the model is not deprecated by the provider"}
}

here message can be made proper.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cool

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will keep it as log.error for now to indicate that the model is not supported by Kaapi.

f"model='{model_name}'. Allowed: {allowed_voices}"
),
logger.warning(
f"[validate_blob_model_or_raise] Voice '{voice}' is not supported for provider='{provider}' "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as above, a bit more explanatory logs. Else could be misleading in the logs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@Prajna1999 The modality checks and completion_type is already implemented in new pr where the completion_type I had set as an array ['text', 'stt']

Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/app/crud/model_config.py`:
- Around line 126-129: The log message in validate_blob_model_or_raise
concatenates two string literals without a separating space, causing
"...provider='{provider}'.Kaapi..." in logs; fix by ensuring a space between the
sentences (e.g., merge into a single f-string or add a trailing space at the end
of the first string or leading space at the start of the second) in the
logger.warning call so the message reads "...provider='{provider}'. Kaapi does
not yet support...".
🪄 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: CHILL

Plan: Pro

Run ID: 40660dee-7473-4ade-9111-eabe3c3b25a8

📥 Commits

Reviewing files that changed from the base of the PR and between 6b017d8 and 786456b.

📒 Files selected for processing (1)
  • backend/app/crud/model_config.py

Comment on lines +126 to 129
logger.warning(
f"[validate_blob_model_or_raise] Model '{model_name}' not found for provider='{provider}'."
"Kaapi does not yet support this model, but will forward as long as the `model` field has no typos and the model is not deprecated by the provider"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing whitespace between concatenated strings.

The two string literals are implicitly concatenated, but there's no space or newline between the period at the end of line 127 and "Kaapi" at the start of line 128. The resulting log message will read ...provider='{provider}'.Kaapi does not....

🔧 Proposed fix
     if model_row is None:
         logger.warning(
             f"[validate_blob_model_or_raise] Model '{model_name}' not found for provider='{provider}'. "
-            "Kaapi does not yet support this model, but will forward as long as the `model` field has no typos and the model is not deprecated by the provider"
+            "Kaapi does not yet support this model, but will forward as long as the `model` field has no typos and the model is not deprecated by the provider."
         )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/crud/model_config.py` around lines 126 - 129, The log message in
validate_blob_model_or_raise concatenates two string literals without a
separating space, causing "...provider='{provider}'.Kaapi..." in logs; fix by
ensuring a space between the sentences (e.g., merge into a single f-string or
add a trailing space at the end of the first string or leading space at the
start of the second) in the logger.warning call so the message reads
"...provider='{provider}'. Kaapi does not yet support...".

@Prajna1999 Prajna1999 merged commit 4ecd3b8 into main Jun 1, 2026
3 checks passed
@Prajna1999 Prajna1999 deleted the chore/model-validation-warning branch June 1, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model Config: relax model validation to warning

3 participants