Repository navigation
Expose ETag on the public quality route - #2400
Merged
neuromechanist merged 5 commits intoNov 26, 2026
Merged
neuromechanist merged 5 commits into
neuromechanist merged 5 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2400Version: 🤖 Updated on each push. |
2 tasks
2 tasks
neuromechanist
merged commit Nov 26, 2026
311c71f
into
feature/issue-2324-epic-pipeline-progress
45 of 53 checks passed
This was referenced Nov 26, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, addsETagtoAccess-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) withOrigin: 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-entersapi.fetch, soroutes/data.tsandroutes/quality.tsare answered by the api's globalcors()inindex.ts.Its preset headers are copied over the handler's response (Hono's
c.ressetter), 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
exposeHeaderslist governs every api route, the admin mount (routes/admin/quality-views.ts) included.Exposing
ETagonly here leaves every other route's exposure exactly as it was.allowHeaders, the origin function andcredentialsare untouched.Tests
ETag, keepX-Request-IdandRetry-After, listETagonce, reflect the origin with credentials, and carry the unchangedETag(the body's SHA-256, the file's digest).ETagtoo.quality_not_found,view_not_declared) is stillno-store, carries noETag, and its expose list is the shared one, withoutETag.ETag(any case) is left as it is, not appended to.ETag.Mutations:
ETagto the global list instead: the admin test fails.Gates:
bun run typecheckandbun run lintpass; targetedquality-route,quality-admin-views,quality-admin-route,compute-jobs-cors,cors-origins(124 pass), plusgit-file-broker,oidc-discovery,rate-limit-response-headers(88 pass). Fullbun testnot run (epic todevgate).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.