Loading
Commits on Source 4
-
Matt Cockayne authored
-
Matt Cockayne authored
-
Maps GitHub's errors onto the forge sentinels released in v0.13.0, so a caller can tell a missing release from a lapsed credential from a permission failure from a rate limit — and respond differently to each, which is the point of them. Rate limiting is checked FIRST, and by type rather than by status. GitHub answers a rate limit with 403, not 429, so a status-ordered mapping would report it as a permission failure; a caller acting on that has no reason to back off, and one that treats forbidden as a credential problem would re-resolve, aiming a burst of resolutions at an API already refusing. go-github parses the limit into *RateLimitError and *AbuseRateLimitError, which is both more reliable than reading headers and impossible to get the order wrong on. A header check backs that up for a path that wrapped its error and lost the type. The two are redundant for the case they share, which the behavioural tests could not tell apart — either alone satisfied them, so the backstop looked load-bearing while being unfalsifiable. Internal tests now exercise each branch on its own, and each dies to its own mutant. Release paths carry ErrReleaseNotFound on a 404. GitHub answers "this repository has no releases" and "this repository does not exist" with the same bare 404 and no way to tell them apart, so the release-specific sentinel is the honest one: it is what the caller asked about, and claiming the repository is missing would assert more than the response says. wrapNotFound now delegates to the shared mapper rather than doing its own 404 check. Its name is narrower than its job, but it is the call at fourteen sites and renaming them would bury the change that matters. The contents sentinels stay with it, being peculiar to that path. An unmapped status stays an ordinary error rather than being forced into one of the four, so a caller branching on the sentinels falls through to its general handling. Implements forge spec 0009 D1, D2, D3 and D7 for this adapter.
-
Matt Cockayne authored