{"record":{"id":"3414f609296f40d5","repo":"goharbor/harbor","slug":"unauthorized-3414f6","errorCode":"UNAUTHORIZED","errorMessage":"security context not found","messagePattern":"security context not found","errorType":"http","errorClass":"errors.UnauthorizedError","httpStatus":401,"severity":"error","filePath":"src/server/v2.0/handler/repository.go","lineNumber":75,"sourceCode":"}\n\nfunc (r *repositoryAPI) Prepare(ctx context.Context, _ string, params any) middleware.Responder {\n\tif err := unescapePathParams(params, \"RepositoryName\"); err != nil {\n\t\tr.SendError(ctx, err)\n\t}\n\n\treturn nil\n}\n\nfunc (r *repositoryAPI) ListAllRepositories(ctx context.Context, params operation.ListAllRepositoriesParams) middleware.Responder {\n\t// set query\n\tquery, err := r.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)\n\tif err != nil {\n\t\treturn r.SendError(ctx, err)\n\t}\n\tsecCtx, ok := security.FromContext(ctx)\n\tif !ok {\n\t\treturn r.SendError(ctx, errors.UnauthorizedError(errors.New(\"security context not found\")))\n\t}\n\tif !secCtx.IsSysAdmin() && !secCtx.IsSolutionUser() {\n\t\tprojectIDs, err := r.listAuthorizedProjectIDs(ctx)\n\t\tif err != nil {\n\t\t\treturn r.SendError(ctx, err)\n\t\t}\n\t\t// no authorized projects, return nil directly\n\t\tif len(projectIDs) == 0 {\n\t\t\treturn operation.NewListAllRepositoriesOK().\n\t\t\t\tWithXTotalCount(0).\n\t\t\t\tWithLink(r.Links(ctx, params.HTTPRequest.URL, 0, query.PageNumber, query.PageSize).String()).\n\t\t\t\tWithPayload(nil)\n\t\t}\n\t\torList := &q.OrList{}\n\t\tfor _, projectID := range projectIDs {\n\t\t\torList.Values = append(orList.Values, projectID)\n\t\t}\n\t\tquery.Keywords[\"ProjectID\"] = orList","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/server/v2.0/handler/repository.go#L57-L93","documentation":"Error \"security context not found\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/server/v2.0/handler/repository.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}