diff --git a/tangled_comment_post.py b/tangled_comment_post.py index 7b11843..9f95104 100644 --- a/tangled_comment_post.py +++ b/tangled_comment_post.py @@ -41,7 +41,14 @@ def scrape_form(doc): uris = re.findall(r'name="subject-uri"[^>]*value="([^"]+)"', doc) idxs = re.findall(r'name="pull-round-idx"[^>]*value="([^"]+)"', doc) if not uris or not idxs: - sys.exit("could not find the comment form (is the cookie still valid?)") + # Two causes, and naming only one sends the reader in the wrong direction: a + # reviewer hitting this on a phantom pull will re-auth, succeed, and still fail. + sys.exit( + "could not find the comment form. Two causes, in likelihood order:\n" + " 1. THE PULL DOES NOT EXIST — a 404 page renders 200 and carries no form.\n" + " Check the branch on the remote, not the pull number.\n" + " 2. the cookie has expired." + ) return uris[-1], idxs[-1] diff --git a/tangled_comments.py b/tangled_comments.py index 6dc7619..f1b70b9 100644 --- a/tangled_comments.py +++ b/tangled_comments.py @@ -86,6 +86,20 @@ def main(): if a.round is not None: url += f"/round/{a.round}" doc = fetch(url, cookie) + + # A 404 page renders 200 and carries no pull record, so "0 comments" used to be + # indistinguishable from "no such pull". On 2026-08-22 that cost a false report that + # #428 was filed and unreviewed, and a reviewer's time chasing it. The post tool never + # had the defect because it MUST resolve a subject-uri to work at all — so require the + # same identifier here, and refuse rather than print a header for a phantom. + if not re.search(r'name="subject-uri"[^>]*value="(at://[^"]+)"', doc): + sys.exit( + f"pull #{a.pull} does not exist in {a.owner}/{a.repo} " + f"(no pull record on {url}).\n" + " This is NOT an auth failure: the page rendered, it simply carries no pull.\n" + " A pull that exists always yields a subject-uri." + ) + comments = parse_comments(doc) if a.json: