Skip to content

Conversation

@bnyashwanth
Copy link

@bnyashwanth bnyashwanth commented Jan 16, 2026

Description

Fixes #244

The application previously crashed with a ValueError if EMBEDDING_MAX_BATCH_SIZE was set to a non-integer value or an invalid string.

Changes

  • Added a try-except block in backend/config.py.
  • If parsing fails, it now logs a warning and defaults to 32 instead of crashing the backend.

Verification

  • Tested locally by setting EMBEDDING_MAX_BATCH_SIZE="invalid_text".
  • Verified that the app starts successfully and logs the warning message:
    Warning: Invalid EMBEDDING_MAX_BATCH_SIZE 'invalid_text'. Defaulting to 32.

Summary by CodeRabbit

  • Bug Fixes
    • Improved robustness of batch-size configuration: invalid or non-positive values now emit a warning and a safe default is applied to prevent startup failures.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Adds guarded parsing and logging to backend/config.py for EMBEDDING_MAX_BATCH_SIZE: invalid or non-positive values are caught, a warning is logged, and MAX_BATCH_SIZE falls back to 32 instead of raising.

Changes

Cohort / File(s) Summary
Configuration Error Handling
backend/config.py
Added logging import and module logger; replaced direct MAX_BATCH_SIZE init with guarded parsing of EMBEDDING_MAX_BATCH_SIZE (int conversion, positive check). On ValueError or non-positive input logs a warning and defaults MAX_BATCH_SIZE to 32. Preserves existing EMBEDDING_MODEL/EMBEDDING_DEVICE behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I sniffed the env and gave a twitch,
I tried to parse but hit a glitch.
I logged a warning, set size to thirty-two,
Now configs hop safe—no crash in view! ✨

🚥 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 and concisely summarizes the main change: adding graceful error handling for invalid EMBEDDING_MAX_BATCH_SIZE values.
Linked Issues check ✅ Passed The PR implementation meets all coding requirements from issue #244: prevents crashes, adds error handling with try-except, logs warnings, and defaults to safe value (32).
Out of Scope Changes check ✅ Passed All changes in backend/config.py are directly scoped to the linked issue: adding logging infrastructure and validating EMBEDDING_MAX_BATCH_SIZE with appropriate error handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 896169a and 1828cf5.

📒 Files selected for processing (1)
  • backend/config.py
🧰 Additional context used
🪛 Ruff (0.14.11)
backend/config.py

22-22: Abstract raise to an inner function

(TRY301)

🔇 Additional comments (2)
backend/config.py (2)

1-5: Good logger setup for config warnings.


18-25: Graceful parsing and fallback looks solid.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

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.

BUG: Invalid EMBEDDING_MAX_BATCH_SIZE Value Triggers ValueError in backend/config.py

1 participant