{"record":{"id":"28f1991c338f6159","repo":"goharbor/harbor","slug":"unable-to-recover-username-for-auto-onboard-usern","errorCode":null,"errorMessage":"unable to recover username for auto onboard, username claim: %s","messagePattern":"unable to recover username for auto onboard, username claim: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/core/controllers/oidc.go","lineNumber":186,"sourceCode":"\t\toc.SendInternalServerError(err)\n\t\treturn\n\t}\n\tu, err := ctluser.Ctl.GetBySubIss(ctx, info.Subject, info.Issuer)\n\tif errors.IsNotFoundErr(err) { // User is not onboarded, kickoff the onboard flow\n\t\t// Recover the username from d.Username by default\n\t\tusername := info.Username\n\t\t// Fix blanks in username\n\t\tusername = strings.Replace(username, \" \", \"_\", -1)\n\t\toidcSettings, err := config.OIDCSetting(ctx)\n\t\tif err != nil {\n\t\t\toc.SendInternalServerError(err)\n\t\t\treturn\n\t\t}\n\t\t// If automatic onboard is enabled, skip the onboard page\n\t\tif oidcSettings.AutoOnboard {\n\t\t\tlog.Debug(\"Doing automatic onboarding\\n\")\n\t\t\tif username == \"\" {\n\t\t\t\toc.SendInternalServerError(fmt.Errorf(\"unable to recover username for auto onboard, username claim: %s\",\n\t\t\t\t\toidcSettings.UserClaim))\n\t\t\t\treturn\n\t\t\t}\n\t\t\tuserRec, onboarded := userOnboard(ctx, oc, info, username, tokenBytes)\n\t\t\tif !onboarded {\n\t\t\t\tlog.Error(\"User not onboarded\\n\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlog.Debug(\"User automatically onboarded\\n\")\n\t\t\tu = userRec\n\t\t} else {\n\t\t\tif err := oc.SetSession(userInfoKey, string(ouDataStr)); err != nil {\n\t\t\t\tlog.Errorf(\"failed to set session for key: %s, error: %v\", userInfoKey, err)\n\t\t\t\toc.SendInternalServerError(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\toc.Controller.Redirect(fmt.Sprintf(\"/oidc-onboard?username=%s&redirect_url=%s\", username, redirectURLStr), http.StatusFound)\n\t\t\t// Once redirected, no further actions are done","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/core/controllers/oidc.go#L168-L204","documentation":"Raised in OIDC Callback during auto-onboard: the username claim extracted from the ID token info is empty, so the system cannot determine which username to auto-onboard the user with.","triggerScenarios":"Thrown at src/core/controllers/oidc.go:186 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Configure the OIDC provider to include a valid username claim in tokens","Set the correct username claim name in Harbor's OIDC settings","Fall back to the manual onboard page where the user enters a username"],"exampleFix":null,"handlingStrategy":"validation","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"}