{"record":{"id":"b173d8fa5fe5428c","repo":"goharbor/harbor","slug":"not-found-b173d8","errorCode":"NOT_FOUND","errorMessage":"repository %s not found","messagePattern":"repository (.+?) not found","errorType":"error_code","errorClass":"lib/errors.Error","httpStatus":404,"severity":"error","filePath":"src/pkg/repository/manager.go","lineNumber":87,"sourceCode":"\t}\n\treturn repositories, nil\n}\n\nfunc (m *manager) Get(ctx context.Context, id int64) (*model.RepoRecord, error) {\n\treturn m.dao.Get(ctx, id)\n}\n\nfunc (m *manager) GetByName(ctx context.Context, name string) (repository *model.RepoRecord, err error) {\n\trepositories, err := m.List(ctx, &q.Query{\n\t\tKeywords: map[string]any{\n\t\t\t\"Name\": name,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(repositories) == 0 {\n\t\treturn nil, errors.New(nil).WithCode(errors.NotFoundCode).\n\t\t\tWithMessagef(\"repository %s not found\", name)\n\t}\n\treturn repositories[0], nil\n}\n\nfunc (m *manager) Create(ctx context.Context, repository *model.RepoRecord) (int64, error) {\n\treturn m.dao.Create(ctx, repository)\n}\n\nfunc (m *manager) Delete(ctx context.Context, id int64) error {\n\treturn m.dao.Delete(ctx, id)\n}\nfunc (m *manager) Update(ctx context.Context, repository *model.RepoRecord, props ...string) error {\n\treturn m.dao.Update(ctx, repository, props...)\n}\n\nfunc (m *manager) AddPullCount(ctx context.Context, id int64, count uint64) error {\n\treturn m.dao.AddPullCount(ctx, id, count)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/repository/manager.go#L69-L105","documentation":"Returned by repository manager GetByName when the List query on Name returns zero rows. The lookup is exact-match on the repository name, so this NOT_FOUND error means no repository record with exactly that name exists in Harbor's database.","triggerScenarios":"Calling GetByName with a name that has never been created (Harbor auto-creates records on first push, so a never-pushed repo has no record); using the wrong separator or case ( Harbor stores names like project/repo and matching is exact); the repository was deleted by retention or API.","commonSituations":"Querying metadata for a repo that exists in the registry but has no DB record yet (image pushed via docker but API metadata queried before record creation); retention policy already removed the repo; typos or URL-encoded names ('project%2Frepo' vs 'project/repo'); replication target not yet synced.","solutions":["Verify the exact name including the project prefix and case, e.g. library/ubuntu not ubuntu","List repositories with a query to confirm the record exists at all","If the image was pushed only to the registry without triggering record creation, trigger the post-push event/scan or use the API that creates the record","If retention deleted it, restore or re-push the image"],"exampleFix":"// before\nrepo, err := repoMgr.GetByName(ctx, \"ubuntu\")\n// err: repository ubuntu not found\n\n// after\nrepo, err := repoMgr.GetByName(ctx, \"library/ubuntu\")\nif err != nil {\n    if errors.IsErr(err, errors.NotFoundCode) {\n        // handle absent repository record\n    }\n}","handlingStrategy":"validation","validationCode":"// Normalize and check the name shape before lookup\nname = strings.Trim(name, \"/\")\nif !strings.Contains(name, \"/\") {\n    return fmt.Errorf(\"repository name must include project prefix: %s\", name)\n}\nrepo, err := repoMgr.GetByName(ctx, name)","typeGuard":null,"tryCatchPattern":"repo, err := repoMgr.GetByName(ctx, name)\nif err != nil {\n    if errors.IsErr(err, errors.NotFoundCode) {\n        // absent record: create placeholder or return 404 to caller\n    }\n    return err\n}","preventionTips":["Always use the fully-qualified project/repository name with exact case","URL-decode repository paths before calling GetByName","Remember records appear on first push; metadata may legitimately be absent"],"tags":["repository","not-found","metadata","exact-match"],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}