{"record":{"id":"16c5e9aba6efc6eb","repo":"kubernetes/kops","slug":"failed-to-marshal-token-data-w","errorCode":null,"errorMessage":"failed to marshal token data: %w","messagePattern":"failed to marshal token data: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/pkibootstrap/pkisigner.go","lineNumber":118,"sourceCode":"\n\treturn NewAuthenticator(hostname, key.Key)\n}\n\nfunc (a *pkiAuthenticator) CreateToken(body []byte) (string, error) {\n\trequestHash := sha256.Sum256(body)\n\n\tdata := AuthTokenData{\n\t\tTimestamp:   time.Now().Unix(),\n\t\tAudience:    AudienceNodeAuthentication,\n\t\tRequestHash: requestHash[:],\n\n\t\tKeyID:    a.keyID,\n\t\tInstance: a.hostname,\n\t}\n\n\tpayload, err := json.Marshal(&data)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal token data: %w\", err)\n\t}\n\n\tsignature, err := a.sign(payload)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to sign token data: %w\", err)\n\t}\n\ttoken := &AuthToken{\n\t\tData:      payload,\n\t\tSignature: signature,\n\t}\n\n\tb, err := json.Marshal(token)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal token: %w\", err)\n\t}\n\treturn AuthenticationTokenPrefix + base64.StdEncoding.EncodeToString(b), nil\n}\n","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/pkibootstrap/pkisigner.go#L100-L136","documentation":"Marshaling the AuthTokenData struct (timestamp, audience, request hash, key ID, instance) to JSON failed. With fixed-type struct fields this cannot fail in practice; the wrap is defensive and an occurrence indicates internal inconsistency or memory pressure.","triggerScenarios":"Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as non-retryable and report — this is an internal error, not a configuration problem","Check for memory pressure on the node","Report as a bug with the wrapped error if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}