Skip to content

multipleOf validation throws DivisionImpossible error for Decimal class, if one of the operands is much bigger than the other. #701

Closed

Description

@emreakg

Modulo operation between two instances of decimal.Decimal classes can throw an decimal.InvalidOperation: [<class 'decimal.DivisionImpossible'>] error if the bigger operand is 28 orders of magnitudes bigger than the other (for a % b we get an error if a > b * 10^28). Relevant stackoverflow thread.

I believe this exception should be caught and tried again with a better precision value. I understand that decimal.Decimal isn't used by json.load. Still, decimal.Decimal is being heavily used by Singer taps and targets for some reason.

Activity

  1. Julian commented on Jul 7, 2020

    @Julian
    Member

    That's something that should be done outside jsonschema -- as you say, jsonschema doesn't deserialize things. It supports Decimals if they've been loaded properly, but it's up to you to set their precision to what you need them to be before handing them to validation, jsonschema can't really know what precision is appropriate.

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

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