phalcon/cphalcon · error · InvalidClaims
Invalid Claims (not an array)
Error message
Invalid Claims (not an array)
What it means
JWT Parser: after base64url-decoding and JSON-decoding the claims segment, the result was not an array. A valid JWT claims payload must decode to a JSON object, so the token is malformed or truncated.
Solutions
- Verify the token string was not altered/truncated before parsing
- Reject the token at the API boundary and request re-authentication
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Encryption/Security/JWT/Token/Parser.zep:86 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/7f885c879bd54847.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Encryption/Security/JWT/Token/Parser.zep:86
return new Token(headers, claims, signature);
}
/**
* Decode the claims
*
* @param string $claims
*
* @return Item
*/
private function decodeClaims(string claims) -> <Item>
{
var decoded;
let decoded = this->decode->__invoke(this->doDecodeUrl(claims), true);
if typeof decoded !== "array" {
throw new InvalidClaims();
}
/**
* Just in case
*/
if isset decoded[Enum::AUDIENCE] && typeof decoded[Enum::AUDIENCE] !== "array" {
let decoded[Enum::AUDIENCE] = [decoded[Enum::AUDIENCE]];
}
return new Item(decoded, claims);
}
/**
* Decodes the headers
*
* @param string $headers
*
* @return ItemView on GitHub (pinned to b7419de9cd)