Repository navigation
fix(file): stop is_parent_folder_exist raising on a missing parent - #18930
Conversation
The miss path calls delete_folder_by_pf_id(parent_id) with one argument, but that method takes (user_id, folder_id). Creating a folder under a parent that was deleted or never existed therefore raises TypeError instead of returning False, and the route reports "Internal server error" rather than the intended "Parent Folder Doesn't Exist!". The call has never worked: the callee already took two arguments in the commit that introduced this one. Dropping it rather than supplying an argument is deliberate -- that recursive delete has not run in any release, so wiring it up now would newly destroy rows as a side effect of an existence check, and this function has no tenant to scope such a delete by.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe parent folder existence check now returns a boolean count result. It no longer deletes the folder when no parent file exists. ChangesParent folder existence check
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The change makes missing-parent folder creation return the intended validation error instead of an internal server error, while leaving valid-parent behavior unchanged. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18930 +/- ##
==========================================
- Coverage 39.25% 39.09% -0.17%
==========================================
Files 54 54
Lines 14911 14911
Branches 117 117
==========================================
- Hits 5854 5829 -25
- Misses 9045 9056 +11
- Partials 12 26 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
FileService.is_parent_folder_existcalls the cleanup helper with one argument:but that method takes two:
So on the one path this function exists to handle — a parent folder that was deleted or never existed — it raises
TypeError: delete_folder_by_pf_id() missing 1 required positional argument: 'folder_id'and never returnsFalse.POST /api/v1/fileswith such aparent_idreports"Internal server error"instead of the intended"Parent Folder Doesn't Exist!".The call has never worked: the callee already took two arguments in the same commit that introduced this call site.
Why drop the cleanup rather than pass an argument
That recursive delete has not executed in any release, so wiring it up now would newly destroy rows as a side effect of an existence check.
is_parent_folder_existalso has no tenant in scope, whiledelete_folder_by_pf_idfilters bytenant_idand would need one to be safe. Removing the dead call keeps the function doing exactly what its name and docstring say.The two tests that touch this monkeypatch it as a one-argument lambda, so the signature is unchanged.
How to test
Before: HTTP 500,
"Internal server error".After: the documented
"Parent Folder Doesn't Exist!"response.