feat(pr): name the scopes behind a compare 404 #85
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pr-compare-scope-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Forgejo's compare handler answers a scope-reduced token with a bare
404carryingCan't read pulls or can't read UnitTypeCode(base repo) orCan't read headRepo UnitTypeCode(head repo), becauseparseCompareInforequires pull read AND code read, each reduced by the token's scopes.fj pr createcompares before creating (to guess a title and body when the repo has no PR template), so a token with an issue scope but no repository scope failed with a raw "not found" that named neither the token, the repo, nor the missing scope, and read like an authentication failure.fj pr searchon the same repo succeeded, which made the failure look impossible to explain by scopes.fj_core::prs::comparenow maps both of those 404 bodies to an error naming the two scopes (read:issueandread:repository), the repo, and the refs being compared, keeping the server's own text as context. Every compare call site (the CLI'spr create, the newpr compare, and the MCPcompare_refstool) routes through that one function, so all three get the mapped error. Any other error, including an unrelated 404, passes through unchanged.Add
fj pr compare <base...head>, which runs exactly that call, so a caller can pre-flight the credentialpr createwill use without falling back to raw HTTP against/api/v1/.... It renders a commit/file summary as text and the full comparison under--json.fj pr createalso skips the compare entirely when both a title and a body are supplied: the compare exists only to guess them, so the scripted case no longer needs the repository scope for that call.Covered by unit tests that build the error from stubbed 404 bodies (base denial, head denial, and an unrelated 404 that must pass through) and by a test that formats the new Fluent messages.
#FJ-64