kubernetes/kops · error
failed to marshal token data: %w
Error message
failed to marshal token data: %w
What it means
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.
Source
Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:118
return NewAuthenticator(hostname, key.Key)
}
func (a *pkiAuthenticator) CreateToken(body []byte) (string, error) {
requestHash := sha256.Sum256(body)
data := AuthTokenData{
Timestamp: time.Now().Unix(),
Audience: AudienceNodeAuthentication,
RequestHash: requestHash[:],
KeyID: a.keyID,
Instance: a.hostname,
}
payload, err := json.Marshal(&data)
if err != nil {
return "", fmt.Errorf("failed to marshal token data: %w", err)
}
signature, err := a.sign(payload)
if err != nil {
return "", fmt.Errorf("failed to sign token data: %w", err)
}
token := &AuthToken{
Data: payload,
Signature: signature,
}
b, err := json.Marshal(token)
if err != nil {
return "", fmt.Errorf("failed to marshal token: %w", err)
}
return AuthenticationTokenPrefix + base64.StdEncoding.EncodeToString(b), nil
}
View on GitHub (pinned to 4c8573c808)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/bootstrap/pkibootstrap/pkisigner.go:118 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/16c5e9aba6efc6eb.
Report an issue: GitHub.