{"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":"func (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}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/server/v2.0/handler/repository.go#L57-L93","documentation":"Type-guard in ListAllRepositories: the security context is expected to be injected into the request context by auth middleware; when security.FromContext(ctx) returns !ok the request bypassed that middleware or the context was malformed, so the API returns Unauthorized. A sentinel guard for a missing context value, not a user mistake.","triggerScenarios":"Thrown at src/server/v2.0/handler/repository.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the request carries valid authentication (auth middleware must populate the security context)","Retry with proper credentials/token","If running behind a proxy, verify auth headers are forwarded correctly"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","contentChangedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}