Fix ObjectDoesNotExist using invalid keyword argument#3534
Fix ObjectDoesNotExist using invalid keyword argument#3534arkid15r merged 2 commits intoOWASP:mainfrom
Conversation
Django's ObjectDoesNotExist exception does not accept keyword arguments. Using `ObjectDoesNotExist(msg=...)` raises a TypeError instead of the intended ObjectDoesNotExist exception, breaking error handling in the mentorship module mutations. Changes: - Replace `ObjectDoesNotExist(msg=...)` with positional arguments - Add ASSIGNEE_NOT_FOUND_MSG constant to follow linter rules - Use variable for f-string message to satisfy EM102 rule Fixes OWASP#3521
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThis PR fixes broken error handling in the mentorship module mutations by correcting Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
arkid15r
left a comment
There was a problem hiding this comment.
Looks good, thank you!
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3534 +/- ##
=======================================
Coverage 85.48% 85.48%
=======================================
Files 461 461
Lines 14240 14240
Branches 1896 1896
=======================================
Hits 12173 12173
Misses 1688 1688
Partials 379 379
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|



Proposed change
Resolves #3521
This PR fixes
ObjectDoesNotExist(msg=...)which causesTypeErrorinstead of the intended exception. Django'sObjectDoesNotExistdoes not accept keyword arguments:This means error handling was completely broken for these code paths - users would see
TypeErrorinstead of proper "not found" messages.Changes
ObjectDoesNotExist(msg=...)with positional argumentsASSIGNEE_NOT_FOUND_MSGconstant to follow linter rules (EM101, TRY003)ObjectDoesNotExist(msg=MODULE_NOT_FOUND_MSG)ObjectDoesNotExist(MODULE_NOT_FOUND_MSG)ObjectDoesNotExist(msg="Assignee not found.")ObjectDoesNotExist(ASSIGNEE_NOT_FOUND_MSG)ObjectDoesNotExist(msg=ISSUE_NOT_FOUND_MSG)ObjectDoesNotExist(ISSUE_NOT_FOUND_MSG)Checklist
make check-testlocally: all warnings addressed, tests passed