-
Notifications
You must be signed in to change notification settings - Fork 564
fix: Ensure adding RailsConfig objects handles None values #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Ensure adding RailsConfig objects handles None values #1328
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1328 +/- ##
===========================================
+ Coverage 70.58% 70.61% +0.02%
===========================================
Files 161 161
Lines 16291 16303 +12
===========================================
+ Hits 11499 11512 +13
+ Misses 4792 4791 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 edge cases in the RailsConfig.__add__ method where adding two config objects with None values for prompts or config_path would cause errors. The fix ensures proper handling of None values when merging configs and includes comprehensive test coverage for the addition functionality.
- Adds null-safety checks for
promptsfield in validation methods - Handles
Nonevalues forconfig_pathwhen joining configuration paths - Introduces comprehensive test suite for
RailsConfigaddition functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| nemoguardrails/rails/llm/config.py | Adds null-safety checks for prompts field and config_path handling |
| tests/rails/llm/test_config.py | Adds comprehensive test coverage for RailsConfig addition scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Thank you @JashG for fixing this bug 👍🏻 can you gpg sign your commit following contributing guidelines? |
663f395 to
dfb4484
Compare
|
@Pouyanpi Done! |
Pouyanpi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you @JashG 👍🏻
Description
The
RailsConfig classallows for adding two config objects. This MR addresses two edge cases where this function throws an error.I ran into this error upstream using the NeMo Guardrails service. Internally, the
/v1/chat/completionsendpoint invokesRailsConfig.__add__when given multiple config IDs. I ran into these two errors when attempting to use this endpoint with multiple sample configs.Related Issue(s)
Checklist