Skip to content

fix: return None instead of raw invalid data in invalid_to_none#237

Open
sniper-noob wants to merge 1 commit intosynthdataco:mainfrom
sniper-noob:fix/invalid-to-none-return-value
Open

fix: return None instead of raw invalid data in invalid_to_none#237
sniper-noob wants to merge 1 commit intosynthdataco:mainfrom
sniper-noob:fix/invalid-to-none-return-value

Conversation

@sniper-noob
Copy link
Copy Markdown
Contributor

@sniper-noob sniper-noob commented Mar 25, 2026

The invalid_to_none() WrapValidator was returning the raw invalid value v instead of None when Pydantic validation failed. This defeated the purpose of the function - malformed miner responses passed through unmodified.

Example of the bug:

  • Miner sends: simulation_output = "not_a_tuple"

  • handler(v) raises ValidationError

  • Function returned "not_a_tuple" instead of None

  • This invalid data then flows into DB storage and CRPS workers

  • With fix: ValidationError -> returns None -> safely handled downstream

The invalid_to_none() WrapValidator was returning the raw invalid value v
instead of None when Pydantic validation failed. This defeated the purpose
of the function - malformed miner responses passed through unmodified.

Example of the bug:
  # Miner sends: simulation_output = "not_a_tuple"
  # handler(v) raises ValidationError
  # Function returned "not_a_tuple" instead of None
  # This invalid data then flows into DB storage and CRPS workers

  # With fix: ValidationError -> returns None -> safely handled downstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant