Devr.AI icon indicating copy to clipboard operation
Devr.AI copied to clipboard

Fix: Handle invalid EMBEDDING_MAX_BATCH_SIZE gracefully

Open bnyashwanth opened this issue 10 months ago β€’ 1 comments

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.

bnyashwanth avatar Jan 16 '26 13:01 bnyashwanth

πŸ“ 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 896169aa3a556d434ebdb67d741e446ecbb61117 and 1828cf58282e5df104af70e00f59cf9895b20307.

πŸ“’ 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.

coderabbitai[bot] avatar Jan 16 '26 13:01 coderabbitai[bot]