Skip to content

Conversation

@itzsudipta
Copy link

@itzsudipta itzsudipta commented Jan 17, 2026

Closes #
The PR is : #244

📝 Description

This PR adds robust error handling for the EMBEDDING_MAX_BATCH_SIZE environment variable. Previously, the application would encounter a ValueError and crash during startup if the environment variable was set to a non-integer string.

This change introduces a try-except block to ensure that if the environment variable is misconfigured, the system gracefully falls back to a default value of 32 and remains operational.

🔧 Changes Made

  • Enhanced Configuration Safety: Wrapped EMBEDDING_MAX_BATCH_SIZE parsing in a try-except block in backend/config.py.
  • Fallback Logic: Implemented a default value (32) to prevent application crashes on invalid input.
  • Improved Stability: Prevents deployment failures caused by simple environment configuration typos.

📷 Screenshots or Visual Changes (if applicable)

N/A: This is a backend logic change for stability.

🤝 Collaboration

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for batch size configuration: invalid or non-integer values are now caught, a warning is logged, and a sensible default (32) is applied automatically to prevent startup or runtime errors. No other behavior or configuration values were changed.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Adds guarded initialization for MAX_BATCH_SIZE in backend/config.py: the int conversion is wrapped in a try/except that logs a warning and defaults to 32 on invalid input instead of raising ValueError.

Changes

Cohort / File(s) Summary
Configuration Error Handling
backend/config.py
Wrapped MAX_BATCH_SIZE int conversion in a try/except ValueError. On failure logs "Invalid integer for EMBEDDING_MAX_BATCH_SIZE. Defaulting to 32." and falls back to 32.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐰 I hopped through config lines with care,
Catching numbers that weren't there.
If parsing trips and loses track,
I set it safe — and bring it back.
Thirty-two comforts the coding lair.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a safety fallback for EMBEDDING_MAX_BATCH_SIZE parsing with 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

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
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

🤖 Fix all issues with AI agents
In `@backend/config.py`:
- Around line 15-19: The except handler for parsing EMBEDDING_MAX_BATCH_SIZE
references the logging module but logging is not imported, which will raise
NameError; fix by adding an import for the logging module at the top of the file
so the except block can call logging.warning without error (ensure logging is
imported before MAX_BATCH_SIZE is defined and used).

@itzsudipta
Copy link
Author

@smokeyScraper Hi there! I created issue #244 and have just uploaded my fix. I noticed a concurrent PR was opened, but I would ask you to consider my PR because it includes error-handling logic that prevents the server from failing to start due to configuration typos.

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