-
Notifications
You must be signed in to change notification settings - Fork 2
Custom flag for validator log table #34
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/app/tests/test_guardrails_api_integration.py (1)
1-196: 🛠️ Refactor suggestion | 🟠 MajorNo tests for the new
include_all_validator_logsfeature.The main feature of this PR — the
include_all_validator_logsflag — has no test coverage. Consider adding at least:
- A test with
include_all_validator_logs=Truethat verifies all validator logs (including passes) are persisted.- A test with the default (
False) that verifies only failure logs are persisted.This would confirm the filtering logic works end-to-end.
🤖 Fix all issues with AI agents
In `@backend/app/api/routes/guardrails.py`:
- Around line 180-181: Replace the explicit equality comparison to False in the
guardrails check with a boolean negation: in the if statement that currently
reads "if include_all_validator_logs == False and isinstance(result,
PassResult):", use "if not include_all_validator_logs and isinstance(result,
PassResult):" so the code uses idiomatic Python and avoids issues when
include_all_validator_logs is a truthy/falsy non-bool; update the condition
where include_all_validator_logs and PassResult are checked.
🧹 Nitpick comments (2)
backend/app/api/routes/guardrails.py (2)
24-28:include_all_validator_logsis a query parameter on a POST endpoint — consider moving it into the request body.Since
payloadis a Pydantic model parsed from the JSON body, FastAPI will treatinclude_all_validator_logsas a query parameter (e.g.,?include_all_validator_logs=true). Mixing body and query params on a POST can be surprising to API consumers. Consider adding this field toGuardrailRequestinstead for a cleaner contract.
163-163: Long signature — consider grouping parameters or wrapping across lines for readability.This is a minor readability nit. The function signature is quite long on a single line.
Suggested formatting
-def add_validator_logs(guard: Guard, request_log_id: UUID, validator_log_crud: ValidatorLogCrud, include_all_validator_logs: bool = False): +def add_validator_logs( + guard: Guard, + request_log_id: UUID, + validator_log_crud: ValidatorLogCrud, + include_all_validator_logs: bool = False, +):
Summary
Target issue is #28.
Explain the motivation for making this change. What existing problem does the pull request solve?
We don't want to populate the validator_log each time a validator has parsed a message. There will be a flag
include_all_validator_logswhich if disabled will populate only failed validator logs. Otherwise, we will populate all logs to the validator_log table.Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Notes
Please add here if any other information is required for the reviewer.
Summary by CodeRabbit
New Features
Bug Fixes / Tests