Repository navigation
Conversation
…ndless redirects The import's clients mapped the upstream client's TooLarge, MetadataTarget and TooManyRedirects to SourceError::Unreachable, which is transient: the preflight answered 502 "the source is unreachable" and the worker retried a download that cannot succeed. They are SourceError::Invalid now: the preflight answers 400 and the worker fails at once, with a message that says what to change: the limit and proxy.max_metadata_bytes (for npm's /-/all, also naming the packages or scopes instead), or the URL. Fixes #777 Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_012e6DJbBFHfotXfRdshLUvS
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #777
Problem
The import's clients turn the upstream client's errors into a
SourceErrorwithSourceError::of(crates/server/src/import/feed.rs). It mapped everything but a status toUnreachable, which is transient. So a document larger thanproxy.max_metadata_bytes, a link-local / cloud-metadata target and a redirect that does not end made the preflight answer 502 "the source is unreachable", and the worker read the same document four times (with its backoff) before it failed. Nothing said what to change.Change
SourceError::ofmapsTooLarge,MetadataTargetandTooManyRedirectstoSourceError::Invalid, which is permanent.TransportandIostayUnreachable; the match is exhaustive now, so a newUpstreamErrorhas to be classified.<url> is larger than the <limit> bytes Forge reads of a metadata document; raiseproxy.max_metadata_bytesto read it/-/all(SourceError::of_listing), the same with, or name the packages or scopes to import instead<url> is a link-local or cloud-metadata address, which Forge does not request<url> redirects more than <max> times; give the URL the source answers atWhere the message reaches the administrator:
POST /admin/repositories/{name}/imports):preflight_erroranswers 400 instead of 502, since the error is no longer transient, with the message as its body.crates/server/src/admin/imports.rsitself is unchanged.last_error; a failed name is a failed item with the message in its detail, and the other names go on (before, an "unreachable" name was retried and then failed the whole import).Web UI
No UI change is needed: the import screen (
web/src/routes/admin/repositories/Import.tsx) shows the preflight's response body, the import'slast_errorand an item's detail as plain text, so the new messages appear as they are.Worth knowing
The npm preflight treats an
Invalidanswer of the search for every package as "no search to walk" and goes on to/-/all. A search page larger than the limit now takes that path as well, rather than ending the preflight with a 502./-/allthen answers, or fails with its own message. A refused target or a redirect loop is caught earlier, by the ping.Tests
import/feed.rs: each of the three errors isInvalid, not transient, and carries the limit and setting, or the URL; a failed transfer is still retried.a_listing_larger_than_forge_reads_fails_at_once_and_says_what_to_do(tests/import.rs): withproxy.max_metadata_bytes = 8192, the preflight answers 400 with the message; an import whose/-/allgrew after it was created fails with the message inlast_errorafter one read of/-/all.endless_redirects_and_a_refused_target_fail_at_once_and_name_the_url: the preflight answers 400 for a ping that redirects to itself and forhttp://169.254.169.254/…; a named package whose packument redirects to itself is a failed item, requested once (6 hits: the request and its 5 redirects), and the other package is imported.With the old mapping put back, 4 of the 5 unit tests and both integration tests fail (the preflight answers 502 "the source is unreachable"); with the fix they pass.
Checks run locally:
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo xtask changelog --check,cargo test -p forge-server --lib import(22 passed),cargo test -p forge-server --test import --test apt_import --test raw_import(27 + 3 + 4 passed). The whole workspace suite and the e2e suite were not run locally.Generated by Claude Code