Catches decode/processing failures in sensor ingest#732
Open
devleo10 wants to merge 2 commits intojlab-sensing:mainfrom
Open
Catches decode/processing failures in sensor ingest#732devleo10 wants to merge 2 commits intojlab-sensing:mainfrom
devleo10 wants to merge 2 commits intojlab-sensing:mainfrom
Conversation
…ed bad content-type paths with explicit 400 responses, and adds regression tests for invalid/empty payloads and unsupported content types.
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
Author
Contributor
Author
|
@jmadden173 @aleclevy Lemme know if this looks good. |
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
400instead of bubbling unhandled exceptions as500.400for unsupportedContent-Typevalues (instead of raisingValueError).What Changed
backend/api/resources/util.pydecode_measurement(...)in guarded error handling.process_measurement_dict(...)path to prevent unhandled exceptions from reaching Flask.co2branch to appendPhotoresistivityinsertion result consistently.501) for unknown measurement types.backend/api/resources/sensor_data.py400response.request.mimetypesoapplication/json; charset=utf-8is handled correctly.backend/api/resources/sensor_data_json.py400instead of exception path).request.mimetypefor robust content-type matching.backend/tests/test_sensor.py400400400/api/sensor/returns400/api/sensor_json/returns400Why
Issue #498 showed decode failures surfacing as unhandled exceptions in production logs (
/api/sensor/), causing internal server errors.This PR ensures malformed client payloads are treated as client errors (
400) with clear response messaging and test coverage.Validation
POST /api/sensor/with invalid octet-stream payload now returns400with decode/processing error message.tests/test_sensor.pypasses with new regression scenarios covering the Fail nicely when failing to decode measurements #498 failure modes.Risk / Impact
400501