{"record":{"id":"b67eb3b1f7f67cb0","repo":"kubernetes/kops","slug":"failed-to-marshal-token-w","errorCode":null,"errorMessage":"failed to marshal token: %w","messagePattern":"failed to marshal token: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/pkibootstrap/pkisigner.go","lineNumber":132,"sourceCode":"\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\n// sign performs a TPM signature with the tpmKey, and sanity checks the result.\nfunc (a *pkiAuthenticator) sign(payload []byte) ([]byte, error) {\n\tbeforeSign := time.Now()\n\n\tdigest := sha256.Sum256(payload)\n\n\tsignature, err := a.signer.Sign(cryptorand.Reader, digest[:], crypto.SHA256)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to sign data: %w\", err)\n\t}\n\n\tklog.Infof(\"signing took %v\", time.Since(beforeSign))\n\n\treturn signature, nil","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/pkibootstrap/pkisigner.go#L114-L150","documentation":"Marshaling the outer AuthToken envelope (data plus signature) to JSON failed; a defensive wrap over what is effectively an infallible struct marshal, so occurrence indicates internal inconsistency.","triggerScenarios":"Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:132 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Non-retryable internal error; report it with the wrapped error","Check for memory pressure on the node","Report as a bug 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"}