hashicorp/terraform · error
provider mirror does not have archive index for previously-r
Error message
provider mirror does not have archive index for previously-reported %s version %s
What it means
In PackageMeta, a 404 on the per-version JSON file is treated as a protocol violation because that version was previously advertised in index.json's version list. The mirror is internally inconsistent, so the query is failed (not silently skipped) with errQueryFailed wrapping this message.
Source
Thrown at internal/getproviders/http_mirror_source.go:194
)
statusCode, body, finalURL, err := s.get(ctx, endpointPath)
defer func() {
if body != nil {
body.Close()
}
}()
if err != nil {
return PackageMeta{}, s.errQueryFailed(provider, err)
}
switch statusCode {
case http.StatusOK:
// Great!
case http.StatusNotFound:
// A 404 Not Found for a version we previously saw in index.json is
// a protocol error, so we'll report this as "query failed.
return PackageMeta{}, s.errQueryFailed(provider, fmt.Errorf("provider mirror does not have archive index for previously-reported %s version %s", provider, version))
case http.StatusUnauthorized, http.StatusForbidden:
return PackageMeta{}, s.errUnauthorized(finalURL)
default:
return PackageMeta{}, s.errQueryFailed(provider, fmt.Errorf("server returned unsuccessful status %d", statusCode))
}
// If we got here then the response had status OK and so our body
// will be non-nil and should contain some JSON for us to parse.
var bodyContent ListInstallationPackagesResponseBody
dec := json.NewDecoder(body)
if err := dec.Decode(&bodyContent); err != nil {
return PackageMeta{}, s.errQueryFailed(provider, fmt.Errorf("invalid response content from mirror server: %s", err))
}
archiveMeta, ok := bodyContent.Archives[target.String()]
if !ok {
return PackageMeta{}, ErrPlatformNotSupported{View on GitHub (pinned to c9def3e214)
Solutions
- Re-run once the mirror has finished publishing a consistent snapshot.
- Fix the mirror publish pipeline so index.json and all version files are written atomically together.
- If a version was deliberately removed, regenerate index.json so it no longer lists it.
Example fix
# before: index.json lists 5.2.0 but 5.2.0.json is missing curl https://mirror/tf/.../aws/5.2.0.json # 404 # after: regenerate the mirror index after adding/removing versions $ tf-provider-mirror sync --prune https://mirror/tf
Defensive patterns
Strategy: try-catch
Validate before calling
// After AvailableVersions succeeds, probe each version file existence
// before handing off to PackageMeta, to detect mirror inconsistency early.
for _, v := range versions {
if !mirrorHasVersionFile(p, v) { /* flag inconsistent version */ }
} Try / catch
var qf getproviders.ErrQueryFailed
if errors.As(err, &qf) && strings.Contains(qf.Error(), "does not have archive index") {
// mirror index/version mismatch: skip this version and report to operator
} Prevention
- Publish index.json and all version files atomically as one snapshot.
- Run mirror generation with --prune so removed versions leave no stale index entries.
- Avoid updating a live mirror while terraform init runs.
When it happens
Trigger: AvailableVersions returned version X for a provider, but GET <host>/<ns>/<type>/X.json then responds 404. Caused by a mirror whose index and per-version files are generated from different snapshots, partial sync, or a race where a version was pruned between the two calls.
Common situations: Mirror being updated while terraform init runs; mirror populated by a job that writes index.json before writing version files (or vice versa); manually edited mirror with stale index entries.
Related errors
- invalid response content from mirror server: %s
- provider mirror returned invalid URL %q: %s
- provider mirror returned invalid provider hash %q: %s
- response has invalid Content-Type: %s
- response has invalid Content-Type: must be application/json
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/8b1c7e4c75f6acdc.
Report an issue: GitHub.