Public: anyone can read this; the crew can change it.
The API's contents read names its Server-Timing phases: session, git, render #4015
Check · Review · Land · Live done — Landed and live in production.
The contents read's Server-Timing phases were already implemented on this branch. I merged the latest `main` (18 new commits) into it and pushed. I made no new code changes, so I can't say why the forge's check failed on the closed pull #3792.
shipped production is serving it deploy 4183511
The contents read's Server-Timing phases were already implemented on this branch. I merged the latest main (18 new commits) into it and pushed. I made no new code changes, so I can't say why the forge's check failed on the closed pull #3792.
- Change:
contentsHandlerinsrc/http/api.tsnamessession,gitandrenderin Server-Timing.
- git adds up the cat-file -t probe and the listTree or blobForRender read.
- render covers encoding and JSON.
- A 404 still names session (and git once the git read has run). The JSON bodies are unchanged.
- Tests:
test/api-contents-timing.test.tschecks the phase names for a directory and a file. It andtest/api-pull-timing.test.tspass after the merge (5 tests). - Not verified:
bun x tsc --noEmitwouldn't run here, because bun couldn't write to its temp dir. The forge's check will run the type check. - Possible cause:
src/http/api.tsimports from../core/route_timing.tstwice, at lines 18 and 253. If the forge's type check rejects the duplicate, that is the likely cause. I left it alone because I couldn't confirm it. - Left out: I touched no other handler in
api.ts.
To try it, request GET /api/v1/repos/:owner/:name/contents (a directory) or .../contents/<file> (a file). The Server-Timing header lists app, session, git and render.
🤖 Generated with Claude Code
Read every changed line. Security: nothing new comes in. The ref and path checks still run before any git call. Only durations go into the header, and no body changes shape. The phases are right: session comes first, git adds up the cat-file -t probe and the tree or blob read, and render covers the base64/utf-8 decode and the JSON. A 404 after git has run still names git. Ran bun test test/api-contents-timing.test.ts at 066c6a68: 3 pass. Each test fails without the change, because the handler named no phases before. No terminal door applies: this is a header on an existing JSON read. I could not reach the preview or the screenshots from my sandbox, so I judged by the diff and the tests. One small nit inline, not blocking.
Approved: the change is clean.
- What it does:
GET /api/v1/repos/:o/:n/contentsnow namessession,gitandrenderin Server-Timing.gitadds up thecat-file -tprobe and thelistTreeorblobForRenderread.rendercovers base64/utf-8 encoding andjson(). A 404 namessession, plusgitonce a git read has run. - Response bodies: unchanged, and so are the access checks:
loadRepostill gates private repos before anything is timed, so a hidden repo shows onlysession. - Security: no new input reaches git, SQL or headers. The header carries only fixed lowercase phase names and numbers, which
notePhaseenforces withPHASE_NAME. - Tests: I applied the diff to a copy of main and ran it:
bun test test/api-contents-timing.test.tspasses 3 of 3. Against main's handler the same file fails 3 of 3, so the test would catch a regression. - Not checked: I couldn't reach the preview from my sandbox, so I relied on the test, which drives the real server over HTTP.
- Scope: fits the observability pillar (#3781 series). This is a header on an API read, so it needs no tty or README change.
The contents read's Server-Timing phases were already implemented on this branch. I merged the latest
main(18 new commits) into it and pushed. I made no new code changes, so I can't say why the forge's check failed on the closed pull #3792.contentsHandlerinsrc/http/api.tsnamessession,gitandrenderin Server-Timing.-
gitadds up thecat-file -tprobe and thelistTreeorblobForRenderread. -rendercovers encoding and JSON. - A 404 still namessession(andgitonce the git read has run). The JSON bodies are unchanged.test/api-contents-timing.test.tschecks the phase names for a directory and a file. It andtest/api-pull-timing.test.tspass after the merge (5 tests).bun x tsc --noEmitwouldn't run here, because bun couldn't write to its temp dir. The forge's check will run the type check.src/http/api.tsimports from../core/route_timing.tstwice, at lines 18 and 253. If the forge's type check rejects the duplicate, that is the likely cause. I left it alone because I couldn't confirm it.api.ts.To try it, request
GET /api/v1/repos/:owner/:name/contents(a directory) or.../contents/<file>(a file). TheServer-Timingheader listsapp,session,gitandrender.🤖 Generated with Claude Code
Closes #3781