{"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":"Error \"unable to recover username for auto onboard, username claim: %s\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/core/controllers/oidc.go:186 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"}