Skip to content

feat: return x-amz-request-id header when serving data links - #392

Merged
krokicki merged 1 commit into
mainfrom
worktree-x2s3-1.3.0-request-id
Jun 22, 2026
Merged

feat: return x-amz-request-id header when serving data links#392
krokicki merged 1 commit into
mainfrom
worktree-x2s3-1.3.0-request-id

Conversation

@krokicki

@krokicki krokicki commented Jun 21, 2026

Copy link
Copy Markdown
Member

Summary

Bumps x2s3 to >=1.3.0,<2 and carries over the new request-id feature so Fileglancer returns it when serving data links.

x2s3 1.3.0 (PR #20) adds an S3-style x-amz-request-id header to every response — but only from a standalone x2s3 server, via x2s3's own RequestIdMiddleware. Fileglancer serves data links through its own FastAPI app using x2s3's FileProxyClient directly, so that middleware never runs for these responses. Bumping the dependency alone would not surface the header.

Changes

  • pyproject.tomlx2s3 >=1.2.0,<2>=1.3.0,<2 (pixi.lock updated to 1.3.0).
  • fileglancer/server.py — add a pure-ASGI RequestIdMiddleware scoped to the /files/ proxy paths (Fileglancer's S3-compatible data-serving surface). It reuses x2s3's generate_request_id() and injects the header on the http.response.start event, so file-streaming responses are unaffected. x-amz-request-id added to CORS expose_headers so browser clients (Neuroglancer/N5/Vizarr) can read it.
  • tests/test_endpoints.py — assert a data-link response carries a well-formed, unique x-amz-request-id, and that non-/files/ endpoints do not.

Why scoped to /files/

x-amz-request-id is an S3 semantic; Fileglancer's S3-compatible surface is the /files/{sharing_key}/... proxy. Scoping keeps the header off the regular /api/ endpoints while matching real-S3 / x2s3 behavior for data links.

Testing

pixi run -e test test-backend — full suite passes (400 tests), including the new header assertions.

@StephanPreibisch @JaneliaSciComp/fileglancer

Bump x2s3 to >=1.3.0,<2. x2s3 1.3.0 (PR #20) adds an S3-style
x-amz-request-id header to every response from a standalone x2s3 server
via its own RequestIdMiddleware. Fileglancer serves data links through
its own FastAPI app using x2s3's FileProxyClient directly, so that
middleware never runs for these responses.

Carry the feature over with a pure-ASGI RequestIdMiddleware scoped to the
/files/ proxy paths (Fileglancer's S3-compatible data-serving surface).
It reuses x2s3's generate_request_id() and injects the header on the
http.response.start event, so streaming responses are unaffected. The
header is added to CORS expose_headers so browser clients
(Neuroglancer/N5/Vizarr) can read it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@krokicki krokicki changed the title feat: return x-amz-request-id header when serving data links (x2s3 1.3.0) feat: return x-amz-request-id header when serving data links Jun 21, 2026
@krokicki
krokicki merged commit 641c7e3 into main Jun 22, 2026
5 checks passed
@krokicki
krokicki deleted the worktree-x2s3-1.3.0-request-id branch June 22, 2026 01:04
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