fix(predict-yield): validate numeric fields and return 422 on bad input - #1347
Open
saidai-bhuvanesh wants to merge 1 commit into
Open
fix(predict-yield): validate numeric fields and return 422 on bad input#1347saidai-bhuvanesh wants to merge 1 commit into
saidai-bhuvanesh wants to merge 1 commit into
Conversation
|
@openhands-agent is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel. A member of the Team first needs to authorize it. |
…003#1234) Rebased onto current main. predict_yield called float() directly on client-supplied area_hectares/avg_temperature/expected_rainfall, so a non-numeric or NaN/inf value raised an unhandled TypeError/ValueError (500) or produced a NaN that silently poisoned the yield formula. Parse each field with explicit type/finite checks and return a 422 with per-field detail when validation fails.
saidai-bhuvanesh
force-pushed
the
fix/1234-predict-yield-422-validation
branch
from
August 15, 2026 05:13
be9e57c to
83abf1d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1234
/predict-yield(ml-service/app.py) converted request fields with barefloat(...)calls and no error handling:"abc"raisedValueError→500.NaNpropagated throughtemp_modifier/rain_modifierintoround(expected_yield, 2), yielding invalid JSON.Fix
Validate each numeric field (
area_hectares,avg_temperature,expected_rainfall): non-numeric or non-finite values return a structured422 { "error": "Validation failed", "details": [...] }response — consistent with the existing/predicthandler — instead of an unhandled500.The existing
area_hectares must be > 0check (422) is preserved after parsing.Files
ml-service/app.pyThis PR was created by an AI agent (OpenHands) on behalf of @saidai-bhuvanesh.