Skip to content

Prevent PUT /cameras/{id} rename from overwriting a different camera - #5

Merged
nathan-v merged 1 commit into
mainfrom
fix/camera-rename-overwrite
Jul 18, 2026
Merged

nathan-v merged 1 commit into
mainfrom
fix/camera-rename-overwrite

Conversation

@nathan-v

Copy link
Copy Markdown
Owner

Description

PUT /cameras/{id} treats a body camera_id different from the path as a rename (delete old file, write new id). It never checked whether the destination id already belonged to a different camera, so PUT /cameras/A with body camera_id: B silently deleted and overwrote camera B's config. This guards the rename branch: if the destination id already exists, return 409 and change nothing.

Related Issue

N/A

Motivation and Context

Silent data-loss / integrity bug: a rename could destroy an unrelated camera's calibration with no error returned. Renames to a free id, and normal in-place updates, are unaffected.

How Has This Been Tested?

  • 171 unit tests pass; ruff check/format clean
  • New tests: rename onto an existing camera returns 409 and both cameras survive unchanged; rename to a free id still succeeds (old id 404s, new id resolves)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project (ruff check and ruff format pass)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes
  • All new and existing tests passed

PUT /cameras/{id} with a body camera_id different from the path treats it
as a rename: it deletes the old file and writes the new id. It never checked
whether that new id already belonged to a different camera, so a rename onto
an existing id silently deleted and overwrote that camera's config.

Guard the rename branch: if the destination id already exists, return 409
and change nothing. Adds tests for the collision (both cameras survive) and
the happy-path rename to a free id.
@nathan-v
nathan-v enabled auto-merge (squash) July 18, 2026 03:08
@nathan-v
nathan-v merged commit 0d0f4b1 into main Jul 18, 2026
3 checks passed
@nathan-v
nathan-v deleted the fix/camera-rename-overwrite branch July 18, 2026 03:10
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.

1 participant