phalcon/cphalcon · error · MissingJwtTypHeader

Invalid Header (missing 'typ' element)

Error message

Invalid Header (missing 'typ' element)

What it means

Raised in Token\Parser::decodeHeaders when the decoded JWT header segment either is not a JSON array/object at all (InvalidHeader) or lacks the mandatory 'typ' element (MissingJwtTypHeader). The input at fault is the base64/URL-decoded header payload of the received token; a well-formed JWT header must include 'typ', so its absence means the token is malformed and cannot be parsed.

Solutions

  1. Ensure the issuing side includes a 'typ':'JWT' header when signing tokens
  2. If integrating with a third-party issuer, wrap/normalize the header before parsing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Encryption/Security/JWT/Token/Parser.zep:117 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/a12a43a859878d77. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Encryption/Security/JWT/Token/Parser.zep:117

    /**
     * Decodes the headers
     *
     * @param string $headers
     *
     * @return Item
     */
    private function decodeHeaders(string headers) -> <Item>
    {
        var decoded;

        let decoded = this->decode->__invoke(this->doDecodeUrl(headers), true);

        if typeof decoded !== "array" {
            throw new InvalidHeader();
        }

        if !isset decoded[Enum::TYPE] {
            throw new MissingJwtTypHeader();
        }

        return new Item(decoded, headers);
    }

    /**
     * Decodes the signature
     *
     * @param Item   $headers
     * @param string $signature
     *
     * @return Signature
     */
    private function decodeSignature(<Item> headers,  string signature) -> <Signature>
    {
        var algo, decoded, encodedSignature;

        let decoded          = "",

View on GitHub (pinned to b7419de9cd)