refactor(stream): remove dead type branches from getIntClaim (#5594)

The jwx library always deserializes numeric claims from a parsed token as
float64, so the int and int64 branches in getIntClaim could never succeed
and were dead code. Keep only the float64 path, which is the one actually
exercised by the token round-trip, and update the comment to document the
library behavior.
This commit is contained in:
Deluan Quintão 2026-06-10 23:15:58 -04:00 committed by GitHub
parent 08fd222791
commit 3b958dd6a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -92,17 +92,10 @@ func paramsFromToken(token jwt.Token) (*params, error) {
return &p, nil return &p, nil
} }
// getIntClaim extracts an int claim from a JWT token, handling the case where // getIntClaim extracts a numeric claim from a JWT token. Numeric claims in a
// the value may be stored as int64 or float64 (common in JSON-based JWT libraries). // parsed token are always deserialized as float64, regardless of the type used
// when encoding.
func getIntClaim(token jwt.Token, key string) int { func getIntClaim(token jwt.Token, key string) int {
var v int
if err := token.Get(key, &v); err == nil {
return v
}
var v64 int64
if err := token.Get(key, &v64); err == nil {
return int(v64)
}
var f float64 var f float64
if err := token.Get(key, &f); err == nil { if err := token.Get(key, &f); err == nil {
return int(f) return int(f)