Skip to content

Forwarding capture metadata problems to users on capture creation#303

Merged
lucaspar merged 4 commits into
masterfrom
lp/sharing-capture-error-info
Jul 1, 2026
Merged

Forwarding capture metadata problems to users on capture creation#303
lucaspar merged 4 commits into
masterfrom
lp/sharing-capture-error-info

Conversation

@lucaspar

@lucaspar lucaspar commented Jun 25, 2026

Copy link
Copy Markdown
Member
  • Script to help manually diagnosing problems with HDF5 files
  • Issues reading Digital-RF files are now passed to users as 4xx errors stemming from a ValueError exception, since they're likely problems with the data, not the system

Note

Medium Risk
Changes HTTP status mapping on capture create/update (400 vs 503) and MinIO/metadata failure paths; behavior is covered by new tests but affects a core ingestion flow.

Overview
Improves capture create/update error handling so users get actionable 4xx responses for bad upload data instead of opaque 5xx failures, while true infrastructure problems still surface as 503.

Digital RF metadata (read_metadata_by_channel): broad OSError from missing/corrupt RF or metadata HDF5 is wrapped in ValueError with re-upload guidance; corrupt metadata@*.h5 after read_flatdict fails is treated the same way (optional digital metadata without dmd_properties still logs and continues).

MinIO file tree reconstruction: fetch errors are split via storage_errors — connectivity/timeouts/service errors raise StorageUnavailableError (→ 503 on capture endpoints); missing objects and other fetch failures raise ValueError with user-facing messages (→ 400). Temp-dir reconstruction uses check_disk_space_available(..., buffer_bytes=0) so the 5GB safety buffer does not block small staging dirs.

Adds scripts/diagnose_metadata_files.py to download capture/file UUIDs from MinIO and report HDF5 health (dmd_properties, metadata@ files). Tests cover storage classification, reconstruct_tree behavior, metadata ValueError, and capture 503 paths.

Reviewed by Cursor Bugbot for commit 122a616. Bugbot is set up for automated code reviews on this repo. Configure here.

@lucaspar lucaspar requested a review from klpoland June 25, 2026 18:41
@lucaspar lucaspar self-assigned this Jun 25, 2026
@lucaspar lucaspar added bug Something isn't working gateway Gateway component labels Jun 25, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 03098e0. Configure here.

Comment thread gateway/sds_gateway/api_methods/helpers/reconstruct_file_tree.py
@lucaspar lucaspar force-pushed the lp/sharing-capture-error-info branch from 122a616 to 068b1ce Compare June 25, 2026 20:11
@lucaspar

Copy link
Copy Markdown
Member Author

rebased

@klpoland klpoland left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this!

lucaspar and others added 4 commits July 1, 2026 15:08
The broad except around fget_object was converting every storage failure,
including MinIO connection errors, into ValueError. Capture create/update
then returned HTTP 400 for infrastructure outages while OpenSearch
connection failures correctly returned HTTP 503.

Classify storage errors with is_storage_unavailable_error(), raise
StorageUnavailableError for unreachable storage, and keep ValueError for
missing or user-actionable fetch failures. Handle StorageUnavailableError
in capture create/update alongside OpenSearch ConnectionError.

Co-authored-by: Lucas Parzianello <lucaspar@users.noreply.github.com>
- Combine nested with statements in test_minio (SIM117)
- Merge storage/OpenSearch 503 handlers in capture update (PLR0911)
- Avoid direct urllib3 import in test_storage_errors (deptry DEP003)
reconstruct_tree was applying the 5GB download safety buffer when
checking space for tiny metadata fetches in tempfile directories, which
failed in CI after deploy when free disk dropped below 5GB.

Skip the buffer for reconstruction (buffer_bytes=0) and mock disk space
in celery email tests that exercise MinIO rather than disk availability.
@lucaspar lucaspar force-pushed the lp/sharing-capture-error-info branch from 068b1ce to f5b6d7c Compare July 1, 2026 19:08
@lucaspar lucaspar merged commit f5b6d7c into master Jul 1, 2026
2 checks passed
@lucaspar lucaspar deleted the lp/sharing-capture-error-info branch July 1, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gateway Gateway component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants