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

web ui setup: the first push to mel/proj was refused once on the check host, cause unknown #17052

Merged opened this

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

Merged

scout/forge:scout/16335-web-ui-setup-the-first-push-to-mel-proj → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/16335-web-ui-setup-the-first-push-to-mel-proj was merged into main as 12f4d33.

Review

Sign in to review this change.
1 file changed +24 −1
test/web-ui.test.ts +24 −1
@@ -101,7 +101,30 @@ describe("web ui", () => {
101101 await git(["add", "."], repo);
102102 await git(["commit", "-q", "-m", "first"], repo);
103103 const remote = `http://mel:web-ui-password@localhost:${servers.port}/mel/proj.git`;
104 await git(["push", "-q", remote, "main"], repo);
104 // The first push is the one #16335 saw refused on the check host once. When it fails, say
105 // what the forge thinks of the repository too, so the log names which cause it was: the
106 // repository missing (`/new`), the credentials (401/403), or the hook.
107 try {
108 await git(["push", "-q", remote, "main"], repo);
109 } catch (e) {

Probe fetches can throw and would mask e. Wrap them, and always rethrow with the git stderr included.

110 // A probe that throws must not replace git's own message.
outdated

No credentials here means a healthy server answers 401 anyway, so the status can't separate the causes. Send authorization: Basic ${btoa("mel:web-ui-password")} so 200/401/403/404 each mean something.

111 const probe = async (what: string, url: string, headers: Record<string, string>) => {
112 try {
113 return `${what} answered ${(await fetch(url, { headers })).status}`;
114 } catch (err) {
115 return `${what} probe failed: ${(err as Error).message}`;
116 }
117 };
118 const seen = await probe("GET /mel/proj", `${base}/mel/proj`, { cookie: owner });
119 const info = await probe(
120 "receive-pack advertisement with mel's credentials",
121 `${base}/mel/proj.git/info/refs?service=git-receive-pack`,
122 { authorization: `Basic ${btoa("mel:web-ui-password")}` },
123 );
124 // 200: repository, credentials and hook path are fine, the refusal came later;
125 // 401/403: the credentials; 404: the repository is missing.
126 throw new Error(`${(e as Error).message}\n(#16335: ${seen}; ${info})`, { cause: e });
127 }
105128 await git(["checkout", "-q", "-b", "topic"], repo);
106129 await writeFile(join(repo, "a.txt"), "two\n");
107130 await git(["commit", "-qam", "second"], repo);

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs