Skip to content

Commit eb6d748

Browse files
committed
docs(java): correct how a 429 from a Maven mirror is described
1 parent 8f734a1 commit eb6d748

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

docs/guide/references/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Recommended mitigations:
138138
- **Populate `~/.m2` before scanning.** Run `mvn dependency:resolve` (or any build step that resolves dependencies) so that every POM is cached locally. In CI, cache the `~/.m2` directory between runs (e.g. keyed on `pom.xml` checksums) so subsequent runs reuse the artifacts.
139139
- **Configure mirrors** of the rate-limited repository, so that POM lookups go to a host that isn't blocking you. There are two ways to do it:
140140
- `<mirrors>` in Maven's [settings.xml][maven-mirror-settings] — the standard mechanism, honored by `mvn` itself as well. A repository is served by a single mirror, so a mirror that is rate-limited too leaves nothing to fall back on.
141-
- [scan.maven.mirrors][maven-mirrors] in `trivy.yaml` — Trivy-specific, and takes an ordered list of mirrors per repository. A mirror that returns `429` is skipped in favor of the next one, and the scan fails only once every mirror of an artifact is rate-limited.
141+
- [scan.maven.mirrors][maven-mirrors] in `trivy.yaml` — Trivy-specific, and takes an ordered list of mirrors per repository. A mirror that returns `429` is skipped in favor of the next one, and if the remaining mirrors do not return the artifact, the scan stops and reports the `429`.
142142
- **Wait for the block to expire.** The `Retry-After` value in the error tells you the minimum wait. Repeated scans during the block will extend it.
143143
- **Use `--offline-scan`** to skip remote lookups entirely and rely only on the local `~/.m2` cache. Be careful: any transitive POM missing from the cache is silently skipped, so populate `~/.m2` first (see above) — otherwise the dependency tree will be incomplete.
144144

pkg/dependency/parser/java/pom/parse.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,8 +845,9 @@ func (p *Parser) fetchPOMFromRemoteRepositories(ctx context.Context, paths []str
845845
}
846846

847847
seen := set.New[string]()
848-
// A 429 only skips the rate-limited mirror; the last one is kept so it can be
849-
// returned if every mirror turns out to be rate-limited.
848+
// A 429 only skips the rate-limited mirror; the last one is kept so it can be returned
849+
// if no other mirror serves the POM. A rate-limited mirror leaves the result unknown,
850+
// so the 429 wins over the "not found" that the remaining mirrors may have returned.
850851
var lastRateLimitErr error
851852
// Try all remoteRepositories by following order:
852853
// 1. remoteRepositories from settings.xml

0 commit comments

Comments
 (0)