Skip to content

Expose ETag on the public quality route - #2400

Merged
neuromechanist merged 5 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2324-etag-expose
Nov 26, 2026
Merged

neuromechanist merged 5 commits into
feature/issue-2324-epic-pipeline-progressfrom
feature/issue-2324-etag-expose

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2399. Part of #2324; unblocks the verify-before-parse step of nemarOrg/website#596.

What changed

  • backend/src/routes/data.ts: a middleware on /:datasetId/quality/* that, after the handler and only on a successful answer, adds ETag to Access-Control-Expose-Headers (once, keeping the shared list).
    It covers the record and file endpoints, cache hits included; the route has no 304 answer.
  • backend/test/quality-route.test.ts: four tests through the real Worker (plus one on an inline Hono app for the listed-once guard) (src/index.ts) with Origin: https://nemar.org, on the data host.
  • CHANGELOG.md: one line under the B2 route entry.

Which CORS layer serves the data plane

The data host fork rewrites to /data/<rest> and re-enters api.fetch, so routes/data.ts and routes/quality.ts are answered by the api's global cors() in index.ts.
Its preset headers are copied over the handler's response (Hono's c.res setter), so a value set in the handler would be lost; hence a middleware that runs after the handler.

Why route-scoped, not the shared list

The shared exposeHeaders list governs every api route, the admin mount (routes/admin/quality-views.ts) included.
Exposing ETag only here leaves every other route's exposure exactly as it was.
allowHeaders, the origin function and credentials are untouched.

Tests

  • The record and a file answer expose ETag, keep X-Request-Id and Retry-After, list ETag once, reflect the origin with credentials, and carry the unchanged ETag (the body's SHA-256, the file's digest).
  • A cache hit exposes ETag too.
  • A refusal (quality_not_found, view_not_declared) is still no-store, carries no ETag, and its expose list is the shared one, without ETag.
  • An expose list that already names ETag (any case) is left as it is, not appended to.
  • The admin quality record path (401 unauthenticated) and the data catalog do not list ETag.

Mutations:

  • Remove the route's middleware: 2 tests fail (record and file, cache hit).
  • Add ETag to the global list instead: the admin test fails.
  • Drop the success-only check: the refusal test fails.
  • Drop the listed-once guard: the inline listed-once test fails.

Gates: bun run typecheck and bun run lint pass; targeted quality-route, quality-admin-views, quality-admin-route, compute-jobs-cors, cors-origins (124 pass), plus git-file-broker, oidc-discovery, rate-limit-response-headers (88 pass). Full bun test not run (epic to dev gate).

Observation, not changed here

The data-plane file handler sets its own Access-Control-Expose-Headers (Accept-Ranges, Content-Length, Content-Range, ETag); for the same reason it is overwritten by the global list, so those are not exposed to an allowed NEMAR origin either. Worth a separate issue if a browser caller needs them.

Agentic AI tools were used.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2400

Version: 0.10.40-PR2400.bcc6106
Commit: bcc6106


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 311c71f into feature/issue-2324-epic-pipeline-progress Nov 26, 2026
45 of 53 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2324-etag-expose branch November 26, 2026 05:25

This branch was previously deployed

1 inactive deployment
npm — bcc6106c Deployed Nov 26, 2026 by neuromechanist via publish #4976
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