Add firewall rule helpers and structured API errors - #29
Conversation
|
Warning Review limit reached
More reviews will be available in 51 minutes and 54 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ChangesFirewall Rules & Enriched Error Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@unifi_controller_api/api_client.py`:
- Around line 501-507: The UnifiAPIError exception being raised in the
controller-side error response handling has a hardcoded method="GET" parameter,
which is incorrect when the actual HTTP operation was POST, PUT, or DELETE.
Replace the hardcoded "GET" string with the actual HTTP method variable that was
used for the request (this should be available in the scope of the code raising
this exception). This ensures the UnifiAPIError.method attribute accurately
reflects the original request method, providing correct diagnostic information
in error contexts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a870da0f-1dc7-4695-aaca-a64726bcdf3d
📒 Files selected for processing (9)
README.mdtests/test_api_error_details.pytests/test_firewall_rules.pytests/test_package_smoke.pyunifi_controller_api/__init__.pyunifi_controller_api/api_client.pyunifi_controller_api/exceptions.pyunifi_controller_api/models/__init__.pyunifi_controller_api/models/firewall_rule.py
Summary
UnifiAPIErrorUnifiFirewallRulewith_extra_fieldspreservationNotes
This intentionally does not add public live-controller smoke tests or environment-specific fixtures. Controller-specific validation remains a maintainer/private validation concern, while the public repo keeps deterministic unit tests.
Validation
python3 -m pytest -q→ 23 passedpython3 -m ruff check .→ all checks passedpython3 -m build→ sdist and wheel built successfullyCloses #27
Closes #28
Summary by CodeRabbit