Skip to content

Add rename_recording endpoint with path validation and collision detection - #122

Merged
loopback merged 1 commit into
feature/video-filename-renamingfrom
copilot/sub-pr-117
Mar 23, 2026
Merged

loopback merged 1 commit into
feature/video-filename-renamingfrom
copilot/sub-pr-117

Conversation

Copilot AI commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Adds backend support for renaming recordings, exposing a POST /rename_recording endpoint for the capture app workflow.

Changes

  • recording_db.pyrename_recording_entry()

    • Rejects absolute paths and .. traversal segments in new_filename
    • Enforces that only the basename may change (parent directory must remain the same)
    • Checks for DB collisions (Recording with matching filename) and filesystem collisions (os.path.exists) before proceeding; raises FileExistsError on conflict
    • Renames the directory on disk if it exists, then updates the DB
  • fastapi.pyPOST /rename_recording

    • Accepts RenameRecordingData (participant, filename, new_filename)
    • Maps FileExistsError → HTTP 409 Conflict, ValueError → HTTP 404

Example

# Accepted: same directory, new basename
rename_recording_entry(db, "p123", "/data/p123/trial_20250101_120000", "/data/p123/trial_20250101_renamed")

# Rejected: path traversal
rename_recording_entry(db, "p123", "/data/p123/trial_A", "/data/p123/../p999/trial_A")
# ValueError: new_filename must not contain '..' path segments

# Rejected: directory change
rename_recording_entry(db, "p123", "/data/p123/trial_A", "/data/p999/trial_A")
# ValueError: new_filename must be in the same directory as the original recording

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] Add rename_recording endpoint Add rename_recording endpoint with path validation and collision detection Mar 23, 2026
Copilot AI requested a review from loopback March 23, 2026 20:33
@loopback
loopback marked this pull request as ready for review March 23, 2026 21:29
@loopback
loopback merged commit 3447169 into feature/video-filename-renaming Mar 23, 2026
1 check passed
@loopback
loopback deleted the copilot/sub-pr-117 branch March 23, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants