python-jsonschema / python-jsonschema/jsonschema

Instance validates if `multipleOf` is an integer, but fails if it's a float

Open
#1,159 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Python
Stars
5k
Forks
671
Avg merge
1d 1h
Merged PRs (30d)
10

Description

from jsonschema import validate

instance = 9007199254740995
validate(instance, schema={"type": "integer", "multipleOf": 11})    # passes
validate(instance, schema={"type": "integer", "multipleOf": 11.0})  # fails

I'm pretty sure that this is a bug, on the basis that the spec says all integer-valued numbers should be treated as integers.

Found via https://github.com/python-jsonschema/hypothesis-jsonschema/pull/103.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two validation calls from the issue and trace the numeric validation path for integer and float-valued multipleOf schemas. Add or update regression coverage so mathematically integer-valued multiples behave consistently, then confirm the example passes and the existing validation tests remain green.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.