Feat/handle data policy#101
Conversation
|
Warning Review limit reached
More reviews will be available in 57 minutes and 11 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ 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: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis PR implements a comprehensive file lifecycle management system with automatic data retention and deletion workflows. Files now track lifecycle state (ACTIVE, PENDING_ORIGINAL_DATA_DELETION, ORIGINAL_DATA_DELETED, PENDING_AUTO_HARD_DELETE), and two scheduled management commands (running daily via Helm cron jobs) automatically mark and delete files based on retention policies with configurable grace periods. ChangesFile Lifecycle Management & Data Retention
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
90347aa to
089aae8
Compare
Adds 2 commands: 1. Delete original data 2. Auto hard delete the file They are paramettrized through settings. The file model is updated to enable and lifecycle_state is added. Note that this boolean might be a bit redundant with other attributes but it makes it clear what has been done automatically by the commands. Tests cover all the new cases. Viewsets & serializers have been updated accordingly.
…elete_files commands
7ede068 to
54af19f
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@src/backend/core/api/viewsets.py`:
- Around line 261-268: media_auth currently only checks readiness and thus
allows stale URLs; update media_auth to apply the same exclusion/filter logic
used elsewhere by excluding FileLifecycleStateChoices.PENDING_AUTO_HARD_DELETE
and filtering created_at >
get_file_hard_delete_cutoff_datetime(include_grace_period=False) before
authorizing access. Locate the media_auth function/method and add the
lifecycle_state exclusion and created_at cutoff filter to its queryset or
authorization check (mirror the logic around the existing
.exclude(...).filter(...)), and make the identical change in the other
media_auth occurrence mentioned (the similar block used elsewhere).
In `@src/backend/dictaphone/settings.py`:
- Around line 271-290: The four retention settings
(ORIGINAL_FILE_DATA_DELETE_AFTER_DAYS,
ORIGINAL_FILE_DATA_DELETE_AFTER_GRACE_PERIOD_DAYS,
FILE_AUTO_HARD_DELETE_AFTER_DAYS, FILE_AUTO_HARD_DELETE_AFTER_GRACE_PERIOD_DAYS)
currently allow negative integers which makes code that uses timezone.now() -
timedelta(days=days) (see core.models usage) behave incorrectly; add validation
when the settings are loaded to ensure each value is non-negative (or enforce a
sensible minimum), and if a value is negative either raise a clear configuration
error or coerce it to the minimum allowed value so lifecycle/ deletion logic
cannot receive negative days. Locate these symbols in settings.py and implement
the check in the settings class initialization or immediately after values are
read so invalid negatives are caught early.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5418267c-154b-4e3c-a476-2b5f12adba8b
📒 Files selected for processing (21)
src/backend/core/admin.pysrc/backend/core/api/__init__.pysrc/backend/core/api/serializers.pysrc/backend/core/api/viewsets.pysrc/backend/core/factories.pysrc/backend/core/management/commands/auto_hard_delete_files.pysrc/backend/core/management/commands/clean_pending_files.pysrc/backend/core/management/commands/delete_original_files_data.pysrc/backend/core/migrations/0012_file_lifecycle_state_file_file_created_915352_idx.pysrc/backend/core/models.pysrc/backend/core/tasks/file.pysrc/backend/core/tests/ai_jobs/test_api_ai_jobs_retry.pysrc/backend/core/tests/commands/test_auto_hard_delete_files.pysrc/backend/core/tests/commands/test_delete_original_files_data.pysrc/backend/core/tests/files/test_api_files_get.pysrc/backend/core/tests/files/test_api_files_list.pysrc/backend/core/tests/test_api_frontend_configuration.pysrc/backend/core/tests/test_tasks.pysrc/backend/dictaphone/settings.pysrc/helm/dictaphone/Chart.yamlsrc/helm/dictaphone/values.yaml
💤 Files with no reviewable changes (1)
- src/backend/core/management/commands/clean_pending_files.py
Avoids bugs in configuration
Makes the frontend integration easier
9c6f8eb to
0c0dbe4
Compare
Checks commits
Summary by CodeRabbit
New Features
Chores