{"record":{"id":"ab3dd336db0dad14","repo":"goharbor/harbor","slug":"unmarshal-token-response-error-v","errorCode":null,"errorMessage":"unmarshal token response error: %v","messagePattern":"unmarshal token response error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/reg/adapter/dockerhub/client.go","lineNumber":106,"sourceCode":"\n\tresp, err := c.client.Do(request)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif resp.StatusCode/100 != 2 {\n\t\treturn fmt.Errorf(\"login to dockerhub error: %s\", string(body))\n\t}\n\n\ttoken := &TokenResp{}\n\tif err = json.Unmarshal(body, token); err != nil {\n\t\treturn fmt.Errorf(\"unmarshal token response error: %v\", err)\n\t}\n\n\tc.token = token.AccessToken\n\t// Tokens issued by /v2/auth/token expire after 10 minutes; refresh 1 minute\n\t// early to avoid using a token that is about to expire.\n\tc.tokenExpiry = time.Now().Add(9 * time.Minute)\n\treturn nil\n}\n\n// ensureToken refreshes the bearer token when it has expired or is close to\n// expiring. It is a no-op for anonymous (unauthenticated) clients.\nfunc (c *Client) ensureToken() error {\n\tif len(c.credential.Identifier) == 0 {\n\t\treturn nil\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif time.Now().Before(c.tokenExpiry) {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/reg/adapter/dockerhub/client.go#L88-L124","documentation":"Error \"unmarshal token response error: %v\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/pkg/reg/adapter/dockerhub/client.go:106 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"}