goharbor/harbor · error
unmarshal repos list
Error message
unmarshal repos list %s error: %v
What it means
getRepos received a 2xx response from Docker Hub but json.Unmarshal of the body into ReposResp failed — the payload does not match the expected schema (API change or HTML error page); the raw body and parse error are wrapped.
Solutions
- Log the body snippet to see what Docker Hub actually returned
- Check for API changes or an HTML login page due to bad credentials
- Update the response struct to match the current Docker Hub API
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at src/pkg/reg/adapter/dockerhub/adapter.go:432 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/7188aaa7d4ee2752.
Report an issue: GitHub.
Appendix: source
Thrown at src/pkg/reg/adapter/dockerhub/adapter.go:432
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode/100 != 2 {
log.Errorf("list repos error: %d -- %s", resp.StatusCode, string(body))
return nil, fmt.Errorf("%d -- %s", resp.StatusCode, string(body))
}
repos := &ReposResp{}
err = json.Unmarshal(body, repos)
if err != nil {
return nil, fmt.Errorf("unmarshal repos list %s error: %v", string(body), err)
}
return repos, nil
}
// getTags gets a page of tags for a repo from DockerHub
func (a *adapter) getTags(namespace, repo string, page, pageSize int) (*TagsResp, error) {
resp, err := a.client.Do(http.MethodGet, listTagsPath(namespace, repo, page, pageSize), nil)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
View on GitHub (pinned to 7b2fd08cc5)