Skip to content

Backwards compatibility break in 6.1.0 release with empty payload #413

Closed
@sjaakkie

Description

@sjaakkie

Hi,

There's a backwards compatibility break in the 6.1.0 release.
If you add an empty array as payload the error "Payload must be a JSON object" pops up if you decode the JWT.

How to reproduce

use Firebase\JWT\JWT;
use Firebase\JWT\Key;

$key = 'yma6Hq4XQegCVND8ef23OYgxSrC3IKqk';
$payload = [];

$jwt = JWT::encode($payload, $key, 'HS256');
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));

Current (version 6.1.0) behaviour
An error pops up in JWT.php line 115 with the message "Payload must be a JSON object"

Expected (version 6.0.0) behaviour
No error occur when decoding JWT.
Variable $decoded is an empty array

Please take a look at this.

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions