Skip to content

fix: address dead UUID check and copy-paste error in upload_chunk#158

Merged
rubenhensen merged 2 commits into
mainfrom
fix/upload-chunk-cleanups
May 16, 2026
Merged

fix: address dead UUID check and copy-paste error in upload_chunk#158
rubenhensen merged 2 commits into
mainfrom
fix/upload-chunk-cleanups

Conversation

@dobby-coder
Copy link
Copy Markdown
Contributor

@dobby-coder dobby-coder Bot commented May 15, 2026

Summary

Two small, self-contained fixes in src/main.rs::upload_chunk per #157:

  • Unreachable invalid_uuid branch. The uuid::Uuid::parse_str check sat after store.get(uuid), but the store is keyed on the same string passed in the URL, so a malformed UUID always tripped None first and the dedicated invalid_uuid reason code was never emitted in metrics. Moved the parse check above the lookup.
  • Copy-paste error string. The missing-end branch reported "Could not read Content-Range start". Now says end.

Closes #157

Test plan

  • cargo build --release — clean
  • cargo test --release — 86 passed, 0 failed
  • cargo clippy --all-targets --release -- -D warnings — clean
  • cargo fmt --all -- --check — clean

Reviewer quickstart: git fetch origin && git checkout fix/upload-chunk-cleanups && cargo build --release && cargo test --release

- Move uuid::Uuid::parse_str above the store.get lookup so the
  'invalid_uuid' reason code is actually reachable when a malformed
  UUID is supplied in the URL. Previously the store.get HashMap lookup
  always returned None first, so the invalid_uuid branch was dead.
- Fix copy-paste error: the missing-end error message said
  'Could not read Content-Range start'; corrected to 'end'.

Closes #157
@dobby-coder dobby-coder Bot requested a review from rubenhensen May 15, 2026 23:38
The previous PR moved the UUID parse check above the store.get lookup
so the 'invalid_uuid' reason code is actually emitted. Add a regression
test that asserts the response body for a malformed UUID contains
reason="invalid_uuid" (pre-fix it would have been
"expired_or_unknown").
@dobby-coder
Copy link
Copy Markdown
Contributor Author

dobby-coder Bot commented May 15, 2026

Added a regression test (upload_chunk_invalid_uuid_reports_invalid_uuid_reason) per the agent's tests-required-on-fixes rule: every fix PR should ship a regression test that would have caught the bug pre-fix.

The test hits PUT /fileupload/not-a-uuid and asserts the JSON body contains reason="invalid_uuid". Pre-fix, the response would have carried reason="expired_or_unknown" (the dead branch), so this pins the new behaviour.

  • 87/87 tests pass
  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets --release -- -D warnings clean

Copy link
Copy Markdown
Contributor Author

@dobby-coder dobby-coder Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed locally — both fixes look correct and minimal. (Cannot self-approve since this PR was opened by the same account.)

  • The invalid_uuid branch was dead code: store.get(uuid) returns None for any malformed UUID first, so the metric reason was unreachable. Moving the Uuid::parse_str check above the store lookup fixes that, and the new upload_chunk_invalid_uuid_reports_invalid_uuid_reason test pins it.
  • Error string typo ("start" → "end") in the missing-end branch — straightforward.

Verified locally:

  • cargo test --release upload_chunk_invalid_uuid_reports_invalid_uuid_reason passes.
  • Rust quality CI (fmt/clippy/test) is green; only Docker image builds are still pending and don't affect this code change.

LGTM — needs a human approval to merge.

@rubenhensen rubenhensen merged commit 935eca6 into main May 16, 2026
6 checks passed
@dobby-coder dobby-coder Bot deleted the fix/upload-chunk-cleanups branch May 16, 2026 20:02
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.

Small cleanups in upload_chunk: dead UUID validation and copy-paste error message

1 participant