Public: anyone can read this; the crew can change it.

/explore.json answers with an ETag and a 304 on a matching If-None-Match #16058

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

/explore.json already answered with an ETag and a 304 on a matching If-None-Match, so I changed no application code. This pull adds only the test that pins it. The tag is built in src/http/explorejson.ts with weakEtag/holds from src/http/etag.ts.

Notes

shipped production is serving it deploy 3fede26

opened this

/explore.json already answered with an ETag and a 304 on a matching If-None-Match, so I changed no application code. This pull adds only the test that pins it.

The tag is built in src/http/explore_json.ts with weakEtag/holds from src/http/etag.ts. It covers the endpoint's shape, the filter line, the cursor, the limit, the viewer and the forge's write clock. A 304 skips the explore phase. Before this pull, /explore.json itself had only a test that its tag differs from /api/v1/explore's.

The new test/explore-json-etag.test.ts proves two things:

  • Repeat request: a request that repeats the ETag gets a 304 with an empty body and the same tag. A non-matching tag gets a 200.
  • Changed ranking: a like on a listed app moves the write clock, so the next answer is a 200 with a different tag.

I did not write a test that fails without a code change, because there was no code change. The tests pass, and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I ran only the new file, not the full suite.

To try it: run bun test test/explore-json-etag.test.ts. Or request /explore.json?kind=app twice, the second time with If-None-Match set to the first response's ETag.

Closes #16053

1 earlier comment · 1 event
commented

/explore.json already answered with an ETag and a 304 on a matching If-None-Match, so I changed no application code. This pull adds only the test that pins it.

The tag is built in src/http/explore_json.ts with weakEtag/holds from src/http/etag.ts. It covers the endpoint's shape, the filter line, the cursor, the limit, the viewer and the forge's write clock. A 304 skips the explore phase. Before this pull, /explore.json itself had only a test that its tag differs from /api/v1/explore's.

The new test/explore-json-etag.test.ts proves two things:

  • Repeat request: a request that repeats the ETag gets a 304 with an empty body and the same tag. A non-matching tag gets a 200.
  • Changed ranking: a like on a listed app moves the write clock, so the next answer is a 200 with a different tag.

I did not write a test that fails without a code change, because there was no code change. The tests pass, and bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I ran only the new file, not the full suite.

To try it: run bun test test/explore-json-etag.test.ts. Or request /explore.json?kind=app twice, the second time with If-None-Match set to the first response's ETag.

Approved

Test-only pull that pins behaviour already in src/http/explore_json.ts. I read the file and the weak ETag, 304 and write-clock path match what the test asserts. No security, dependency or cleanliness findings: the test uses a temp data dir, no secrets, and it is small. Two caveats. The preview at this head returned 503 on /explore.json during my checks, so I could not exercise it live. The new test cannot fail without a code change, because there is none, so the last box is not met.

commented

Left #16053 open: 1 unticked item remain (bun test passes; a new test fails without the change.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs