remove unused code and raise an excpetion for chown_dir - #175
Conversation
Walkthrough
ChangesDLU filesystem behavior
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ 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
🧹 Nitpick comments (1)
data_management/services/dlu_filesystem.py (1)
115-116: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename the variable
dirto avoid shadowing the built-in function.Using
diras a variable name shadows the Python built-in functiondir(). It is recommended to usedirnameinstead.♻️ Proposed refactor
- for dir in dirs: - subdir_path = os.path.join(root, dir) + for dirname in dirs: + subdir_path = os.path.join(root, dirname)Source: Linters/SAST tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 30f70637-7cf2-43e0-8dc0-35ea51e2fbde
📒 Files selected for processing (1)
data_management/services/dlu_filesystem.py
| except Exception as e: | ||
| logger.error("Error changing ownership of directory %s: %s", package_path, str(e)) | ||
|
|
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Re-raise the exception after logging to prevent false successes.
The PR title indicates the intent is to raise an exception for chown_dir failures. Currently, the exception is caught and logged, but not re-raised. As shown in the context snippet from data_management/watch_files.py, downstream callers do not check for failure and will incorrectly proceed to insert file records and mark the package upload as a "success" even if chown_dir fails.
Additionally, you can use logger.exception to automatically include the stack trace instead of manually casting e to a string.
🐛 Proposed fix to re-raise the exception
- except Exception as e:
- logger.error("Error changing ownership of directory %s: %s", package_path, str(e))
+ except Exception:
+ logger.exception("Error changing ownership of directory %s", package_path)
+ raise📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| except Exception as e: | |
| logger.error("Error changing ownership of directory %s: %s", package_path, str(e)) | |
| except Exception: | |
| logger.exception("Error changing ownership of directory %s", package_path) | |
| raise |
🧰 Tools
🪛 Ruff (0.15.21)
[warning] 119-119: Do not catch blind exception: Exception
(BLE001)
Summary by CodeRabbit
Bug Fixes
Improvements