Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseIntEnum is not handled properly in the Buildarr config parsing #91

Closed
2 tasks done
Callum027 opened this issue Apr 10, 2023 · 1 comment · Fixed by #95
Closed
2 tasks done

BaseIntEnum is not handled properly in the Buildarr config parsing #91

Callum027 opened this issue Apr 10, 2023 · 1 comment · Fixed by #95
Assignees
Labels
bug Something isn't working config Issue or pull request related to Buildarr or plugin configuration secrets Issue or pull request related to instance secrets management
Milestone

Comments

@Callum027
Copy link
Member

Callum027 commented Apr 10, 2023

The following bugs occur in the current version of Buildarr:

  • BaseIntEnum has no specific handlers in the default decoder and formatting functions
  • When BaseIntEnum objects are exported using the JSON/YAML encoder, the BaseIntEnum encoder does not get used as BaseIntEnum is a subclass of int, so the default behaviour is used:
    jellyseerr:
      ...
      settings:
        ...
        users:
          default_permissions:
          - 1048576  # Should be 'MANAGE-ISSUES'
          - 32  # Should be 'REQUEST'
@Callum027 Callum027 added bug Something isn't working config Issue or pull request related to Buildarr or plugin configuration secrets Issue or pull request related to instance secrets management labels Apr 10, 2023
@Callum027 Callum027 added this to the v0.4.2 milestone Apr 10, 2023
@Callum027 Callum027 self-assigned this Apr 10, 2023
@Callum027
Copy link
Member Author

Callum027 commented Apr 12, 2023

It turns out this is a really tough nut to crack.

The JSON library, and literally every third-party library I've found handle built-in types as a special case, and their serialisation behaviour cannot be overridden, even by putting it in the method passed to the default parameter.

With orjson you can tell it to pass through subclasses of cardinal types such as int, and this works, but because IntEnum is a subclass of int and Enum, for some reason it does not get handled by this (it might be a bug, it might not, I don't know.)

It's looking like this might be impossible to implement, short of creating my own whole JSON library just for fixing this problem. And that's way too much work for simply being able to use integer enums wherever int values can go.

If it's not feasible to handle it properly, BaseIntEnum should be deprecated, any uses of it changed back to regular BaseEnums, and removed in the next backward-incompatible release of Buildarr (v0.5.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working config Issue or pull request related to Buildarr or plugin configuration secrets Issue or pull request related to instance secrets management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant