Skip to content

fix(ci): forward the client Host through the dev-server proxy - #39

Closed
michielbdejong wants to merge 1 commit into
mainfrom
claude/fix-notion-live
Closed

michielbdejong wants to merge 1 commit into
mainfrom
claude/fix-notion-live

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

The failure

node integrations/tooling/run-lane.mjs notion --tier live — CI's "Lane: notion (live,e2e)" — fails in integrations/notion/atomic.live.test.ts:

AtomicError: Authentication failed: Unauthorized. Error checking authentication headers.
Incorrect signature for auth headers. ... Compare this to the serialized message in the
client: http://localhost:19140/did?subject=did%3Aad%3A... 1790081327781
Error: This workspace is not available on AtomicServer.

It fails on the very first authenticated request the installer makes: install() → requireInstallationServer(store, drive) → GET {serverUrl}/did?subject=….

Root cause

In this repo, in integrations/tooling/dev-server.mjs. The proxy half sent every request upstream with the Host header rewritten to the upstream's host:port:

headers: { ...req.headers, host: upstreamUrl.host },

Two upstream facts make that fatal:

  • atomic-server derives the origin it answers a request under from Host (server/src/context.rs::RequestContext::new). With ATOMIC_DOMAIN=localhost, host_is_served_here returns true for every host, so the header wins over the configured origin.
  • That origin is exactly what signed auth headers are verified against: lib/src/authentication.rs::check_auth_signature recomputes message = format!("{} {}", subject, timestamp) from the server-side URL.

@tomic/lib signs the URL it is about to fetch, built from the store's serverUrl — the dev-server (browser/lib/src/client.ts, url = ${baseUrl}/did?subject=… then signRequest(url, …)). So the client signs http://localhost:19141/did?subject=…, the proxy hands atomic-server a Host of localhost:19140, the server rebuilds http://localhost:19140/did?subject=…, the ports differ, and the Ed25519 check fails. Every authenticated request through the proxy is a 401 — /did, /commit, /plugin-secret, all of them.

Evidence, with the stack up on the notion lane's ports:

  • through the dev-server (ATOMIC_NOTION_TEST_SERVER=http://localhost:19141): the auth error above.
  • straight at atomic-server (…=http://localhost:19140, same running server, only the proxy bypassed): the auth error is gone entirely and the test runs on through requireInstallationServer and /plugin-secret.
  • with this change: atomic-server logs RequestContext { origin: "http://localhost:19141" } and the lane passes.

Pre-existing, not a regression from the lane split

It arrived with the dev-server itself, in 458f169 ("host plugins over HTTP instead of embedding them in atomic-server"), which repointed the live tier from atomic-server directly (:9883) to the proxy. It has never been observed because no CI run since has reached the Live test: notion step — every run on that workflow failed at an earlier step, and the runs that went green had the whole integration job path-filtered out. #37's per-lane split is simply the first thing that let the notion lane get there.

The fix

Forward Host unchanged, which is what a transparent proxy should do and what the file's own docstring promises ("a single URL behaves like one atomic-server that happens to host this repo's plugin catalog"). Plus a regression test in dev-server.test.mjs asserting the upstream sees the client's Host.

Verification

  • node integrations/tooling/run-lane.mjs notion --tier live → Test Files 5 passed (5), Tests 21 passed (21), notion: live passed (was 1 file / 1 test failing).
  • node --test integrations/tooling/dev-server.test.mjs → 6/6.
  • node integrations/tooling/certify.mjs --layer js → passed.
  • oxlint and oxfmt --check over integrations → clean (only the pre-existing no-console warnings).

Not verified: the e2e tiers do not run to completion in this local environment (pets --tier e2e times out in page.waitForURL). That failure is identical with and without this change — checked by running it on bbb995c alone and on bbb995c + this commit — so this is neutral for e2e, but CI is where e2e gets its real check.

🤖 Generated with Claude Code

The notion lane's live tier failed with "Authentication failed:
Unauthorized. Error checking authentication headers. Incorrect signature
for auth headers", on the very first authenticated request the installer
makes (`requireInstallationServer` -> `GET /did?subject=...`).

The cause is in this repo, in the proxy half of dev-server.mjs. It sent
every proxied request upstream with `host` rewritten to the upstream's
`host:port`. atomic-server derives the origin it answers a request under
from `Host` (server/src/context.rs::RequestContext::new; with
ATOMIC_DOMAIN=localhost every host is "served here", so the header wins
over the configured origin), and that origin is the message signed auth
headers are verified against (lib/src/authentication.rs, `message =
format!("{} {}", subject, timestamp)`). @tomic/lib signs the URL it is
about to fetch, which is built from the store's serverUrl — the
dev-server. So the client signed `http://localhost:19141/did?subject=...`
and atomic-server rebuilt `http://localhost:19140/did?subject=...`; the
ports differ, the signature does not verify, and every authenticated
request through the proxy is a 401.

Forwarding the header unchanged makes the proxy transparent: with
ATOMIC_SERVER_CHECKOUT=/tmp/atomic-server-pin the server now logs
`RequestContext { origin: "http://localhost:19141" }` and
`run-lane.mjs notion --tier live` passes 5 files / 21 tests, where it
previously failed 1.

Not a regression from the per-lane CI rework: it arrived with the
dev-server itself in 458f169, and no CI run since has reached the "Live
test: notion" step — every one failed at an earlier step — so it has
never been observed until the lane split let the notion lane run on its
own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@michielbdejong

Copy link
Copy Markdown
Contributor Author

This PR was merged into #38

auto-merge was automatically disabled September 22, 2026 13:33

Pull request was closed

@michielbdejong
michielbdejong deleted the claude/fix-notion-live branch September 22, 2026 14:58
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