Skip to content

ExpiredSignature should perhaps not be a subclass of DecodeError #606

Closed

Description

@joelmichael

This caused some confusion for us. If a JWT token is expired, this doesn't mean it failed to decode. We were checking for when JWT tokens don't decode correctly due to a formatting error, but this was also catching the case where a (perfectly legitimately encoded) JWT token simply had expired. Thus it affected our error handling for expired tokens unexpectedly.

image

Activity

  1. anakinj commented on Jul 23, 2024

    @anakinj
    Member

    Currently all the errors are subclasses of this DecodeError, so your suggestion (that is perfectly reasonable) applies for all the errors. I agree that some kind of intermediate subclassing logic would make sense.

    Think revamping the error hierarchy could be a chore for the next major release, to allow possible breaking changes.

  2. jkarmel commented on Jul 24, 2024

    @jkarmel

    Thanks @anakinj! I just wanted to second this - because we use Rails' rescue_from on both DecodeError in general and ExpiredSignature in particular but have different handling for each error. Because ExpiredSignature inherits from DecodeError we now have to order the rescue_from blocks in a specific order which feels pretty brittle.

    Appreciate this library, which has been great overall!

  3. added this to the Version 3.0 milestone on Sep 29, 2024
  4. anakinj commented on Sep 29, 2024

    @anakinj
    Member

    Structure to the errors would be great. Some help trying to create some hierarchy appreciated.

  5. anakinj commented on Mar 27, 2026

    @anakinj
    Member

    Some Friday night fiddling in #722 related to this. Would appreciate if @jkarmel or/and @joelmichael would be able to take a look. Goal was to keep the errors backwards compatible.

  6. removed this from the Version 3.0 milestone on Mar 27, 2026
  7. jkarmel commented on Mar 31, 2026

    @jkarmel

    Hiya - we moved to Python for our project so we aren't actively developing on this anymore. Appreciate this awesome lib though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions