Skip to content

bug: ValueError: Out of range float values are not JSON compliant #2213

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

Closed
1 task
dgawlowsky opened this issue Feb 3, 2024 · 8 comments · Fixed by #3019
Closed
1 task

bug: ValueError: Out of range float values are not JSON compliant #2213

dgawlowsky opened this issue Feb 3, 2024 · 8 comments · Fixed by #3019
Assignees
Labels
kind/Bug Something isn't working valuestream/SDK
Milestone

Comments

@dgawlowsky
Copy link
Contributor

Singer SDK Version

0.34.1

Is this a regression?

  • Yes

Python Version

3.9

Bug scope

Taps (catalog, state, etc.)

Operating System

MacOS

Description

I get ValueError: Out of range float values are not JSON compliant when trying to sync Amazon Document DB collection.

The probably reason is that simple_json.dumps() has allow_nan=False default, while standard dumps() function from standard json library has allow_nan=True.

As there is no way to pass configuration from outside could we add this functionality? I can introduce relevant fix.

Code

No response

@dgawlowsky dgawlowsky added kind/Bug Something isn't working valuestream/SDK labels Feb 3, 2024
@edgarrmondragon
Copy link
Collaborator

edgarrmondragon commented Feb 3, 2024

Hi @dgawlowsky, thanks for logging!

I think having allow_nan by default would violate the interoperability principle in the Singer ecosystem since it's specific to Python's JSON implementation: while most taps and targets are written in Python, they could be programmed in any language.

There's also the question of how the jsonchema library that we use for validation on the target side would treat the NaN values, although it's now possible to disable validation on the user end (631d5df), if they're fine with moving NaNs around and skipping schema validation.

Do start a PR and we can discuss the details there!

Related: #2211

@dgawlowsky
Copy link
Contributor Author

Hi @edgarrmondragon - thanks for prompt response again. Opened PR with this one line change. Let's discuss there.

@menzenski
Copy link
Contributor

Also running into this issue, and also in an AWS DocumentDB context.

@edgarrmondragon
Copy link
Collaborator

@menzenski the situation should've improved somewhat with v0.45.6, which shipped

Can you confirm if that's enough for your use case or do you need to actually communicate the NaN values to the target somehow?

@menzenski
Copy link
Contributor

@edgarrmondragon I updated my tap-mongodb fork from 0.41.0 to 0.45.11 today. The changes you mention had no effect for me, but looking at the code I think that's expected - the issues I am experiencing are in the values of a field that I declare as just dict[str, Any] in the schema. I think the changes in 0.45.6 only apply automatically to fields that are typed as float within the tap schema. (So, I think I need to basically make that same change within my tap's code. I'm working on that today).

@edgarrmondragon
Copy link
Collaborator

Ok, I'm now convinced that we should just force those values to be encoded as null in the Singer message across the board.

Does that make sense for your use case @menzenski?

@edgarrmondragon edgarrmondragon self-assigned this May 5, 2025
@edgarrmondragon edgarrmondragon modified the milestones: v0.46, v0.45 May 5, 2025
@menzenski
Copy link
Contributor

Does that make sense for your use case @menzenski?

Yes - for my use case it would be awesome to have it handled globally like that

@menzenski
Copy link
Contributor

@edgarrmondragon thanks for making that change so fast. I've tested meltano/sdk commit b3a7cb3 in my tap and it solves this for me. very very appreciated!

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