{"record":{"id":"554a9cada643a786","repo":"goharbor/harbor","slug":"empty-realm","errorCode":null,"errorMessage":"empty realm","messagePattern":"empty realm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/reg/adapter/gitlab/client.go","lineNumber":49,"sourceCode":"\t\"github.com/goharbor/harbor/src/pkg/reg/util\"\n)\n\n// Client is a client to interact with GitLab\ntype Client struct {\n\tclient   *common_http.Client\n\turl      string\n\tusername string\n\ttoken    string\n}\n\n// NewClient creates a new GitLab client.\nfunc NewClient(registry *model.Registry) (*Client, error) {\n\trealm, _, err := util.Ping(registry)\n\tif err != nil && !liberrors.IsChallengesUnsupportedErr(err) {\n\t\treturn nil, err\n\t}\n\tif realm == \"\" {\n\t\treturn nil, fmt.Errorf(\"empty realm\")\n\t}\n\tlocation, err := url.Parse(realm)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := &Client{\n\t\turl:      location.Scheme + \"://\" + location.Host,\n\t\tusername: registry.Credential.AccessKey,\n\t\ttoken:    registry.Credential.AccessSecret,\n\t\tclient: common_http.NewClient(\n\t\t\t&http.Client{\n\t\t\t\tTransport: common_http.GetHTTPTransport(\n\t\t\t\t\tcommon_http.WithInsecure(registry.Insecure),\n\t\t\t\t\tcommon_http.WithCACert(registry.CACertificate),\n\t\t\t\t),\n\t\t\t\tTimeout: config.RegistryHTTPClientTimeout(),\n\t\t\t}),\n\t}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/reg/adapter/gitlab/client.go#L31-L67","documentation":"Returned by NewClient when the GitLab registry's /v2/ ping succeeds but the WWW-Authenticate challenge contains no realm URL. Without a realm, the client cannot build the token-auth endpoint, so client construction is aborted. It indicates the registry did not advertise a usable OAuth2/token realm (misconfigured registry or non-bearer auth setup).","triggerScenarios":"Thrown at src/pkg/reg/adapter/gitlab/client.go:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the GitLab registry URL points to the container registry endpoint and answers /v2/ with a bearer challenge","Check that GitLab's container registry token auth is enabled and the realm is advertised","Confirm the registry is a GitLab registry; other registries need a different adapter","Capture the /v2/ response headers to inspect the WWW-Authenticate challenge"],"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"}