fix(api): handle invalid project IDs when creating environments#6874
fix(api): handle invalid project IDs when creating environments#6874MartinLam12 wants to merge 5 commits intoFlagsmith:mainfrom
Conversation
|
@MartinLam12 is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Free Tier Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
api/tests/unit/environments/permissions/test_unit_environments_permissions.py
Outdated
Show resolved
Hide resolved
|
Hi @MartinLam12 , thanks for the contribution. Could you please update the PR title as per this failing CI check, and also resolve the comment review from Cursor? |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
I updated the PR title and also resolved the comment review from Cursor. |
|
@matthewelwell Hello, can you take another look? Thanks |
| assert result is False | ||
|
|
||
|
|
||
| # created additional tests to cover edge cases around project ID validation in environment creation |
There was a problem hiding this comment.
| # created additional tests to cover edge cases around project ID validation in environment creation |
I appreciate the description here, but this comment should not live in the code. It is commentary around the PR, not the code necessarily. This type of commentary should be included in the PR description and/or a comment from a self-review, we don't want it to live permanently in the code.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6874 +/- ##
==========================================
- Coverage 98.31% 98.24% -0.08%
==========================================
Files 1335 1335
Lines 49730 49617 -113
==========================================
- Hits 48892 48746 -146
- Misses 838 871 +33 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Contributes to
Please describe.
Handle invalid project values in POST /api/v1/environments/ by catching ValueError and TypeError in EnvironmentPermissions.has_permission(). Previously, passing a non-integer value (e.g., "") caused an unhandled ValueError resulting in a 500 error. The permission check now returns False for invalid project IDs, returning a 403 instead of a 500
How did you test this code?
Please describe.
Added two unit tests in test_unit_environments_permissions.py: test_create_environment__invalid_project_id_string__returns_false — verifies a non-numeric string project ID returns False test_create_environment__none_project_id__returns_false — verifies a missing/null project ID returns False