Skip to content

feat(download): add minimal DRS 1.5 object endpoint#2296

Open
jhagberg wants to merge 5 commits intofeature/sda-download-v2from
feature/drs-object-endpoint
Open

feat(download): add minimal DRS 1.5 object endpoint#2296
jhagberg wants to merge 5 commits intofeature/sda-download-v2from
feature/drs-object-endpoint

Conversation

@jhagberg
Copy link
Contributor

@jhagberg jhagberg commented Mar 6, 2026

Related issue(s) and PR(s)

This PR closes #2246 (SDA-side work only; htsget-rs DrsStorage contribution is separate).

Related: umccr/htsget-rs#356

Description

Adds GET /objects/{datasetId}/{filePath} — a minimal GA4GH DRS 1.5 endpoint that resolves a dataset + file path to a DrsObject with a pre-resolved access_url pointing to /files/{fileId}/content.

Changes:

  • Database: Added CreatedAt to File struct, new GetFileChecksums method for querying checksums by source (ARCHIVED/UNENCRYPTED)
  • Handler: handlers/drs.go — path parsing, auth, file resolution, DRS response construction
  • Route: GET /objects/*path registered with auth middleware
  • Swagger: Endpoint + DRS schemas (DrsObject, DrsChecksum, DrsAccessMethod, DrsAccessURL)

DRS 1.5 compliance:

  • size = ArchiveSize (encrypted blob size per spec: "blob size in bytes")
  • checksums from ARCHIVED source (per spec: "computed over the bytes in the blob")
  • self_uri, created_time, access_methods all per DRS 1.5 required fields

Note: The htsget-rs maintainer pivoted to a ResolveStorage backend using the existing /datasets/{id}/files?filePath= endpoint. This DRS endpoint is an independent, spec-compliant addition with value for any DRS-aware tooling.

ADR

  • This PR includes an architecturally significant decision (see docs/decisions/README.md)
    • A decision record has been added or updated in docs/decisions/

How to test

cd sda && go test ./cmd/download/... -count=1
cd sda && go test -tags visas -count=1 ./cmd/download/...

10 unit tests covering: success path, 403 (not found + no access), 400 (malformed paths), 401, 500, empty checksums, multiple checksums, checksum type normalization. Route wiring test verifies auth requirement.

jhagberg added 4 commits March 3, 2026 16:01
DRS 1.5 requires size and checksums to describe the blob bytes
served by access_url. Changed from DecryptedSize/UNENCRYPTED to
ArchiveSize/ARCHIVED. Added GetFileChecksums DB method to return
all checksums for a given source, supporting multiple algorithms.
@jhagberg jhagberg requested a review from a team as a code owner March 6, 2026 08:07
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 72.94118% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.50%. Comparing base (bca6183) to head (eecfa9c).

Files with missing lines Patch % Lines
sda/cmd/download/database/database.go 10.52% 17 Missing ⚠️
sda/cmd/download/handlers/drs.go 93.44% 3 Missing and 1 partial ⚠️
sda/cmd/download/database/cache.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                     Coverage Diff                     @@
##           feature/sda-download-v2    #2296      +/-   ##
===========================================================
+ Coverage                    42.29%   42.50%   +0.21%     
===========================================================
  Files                          120      121       +1     
  Lines                        12242    12327      +85     
===========================================================
+ Hits                          5178     5240      +62     
- Misses                        6432     6454      +22     
- Partials                       632      633       +1     
Flag Coverage Δ
unittests 42.50% <72.94%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sda/cmd/download/handlers/handlers.go 72.22% <100.00%> (+1.63%) ⬆️
sda/cmd/download/database/cache.go 77.63% <0.00%> (-1.04%) ⬇️
sda/cmd/download/handlers/drs.go 93.44% <93.44%> (ø)
sda/cmd/download/database/database.go 64.51% <10.52%> (-3.53%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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