Skip to content

Sensor and data stream modules do not check payload data validity #716

@mstenta

Description

@mstenta

Describe the bug

Saw a few errors on one of the instances I host. Seems like invalid data was being sent to a sensor, and farmOS code doesn't check for that. These are the two specific errors I saw, one in the farm_sensor module and one in the data_stream module:

TypeError: Drupal\farm_sensor\Controller\SensorDataController::getUniqueNamedValues(): Argument #1 ($data) must be of type array, null given, called in /opt/drupal/web/profiles/farm/modules/asset/sensor/src/Controller/SensorDataController.php on line 138 in Drupal\farm_sensor\Controller\SensorDataController->getUniqueNamedValues() (line 186 of /opt/drupal/web/profiles/farm/modules/asset/sensor/src/Controller/SensorDataController.php) 
TypeError: Drupal\data_stream\Plugin\DataStream\DataStreamType\Basic::storageSave(): Argument #2 ($data) must be of type array, null given, called in /opt/drupal/web/profiles/farm/modules/core/data_stream/src/Plugin/DataStream/DataStreamType/Basic.php on line 320 in Drupal\data_stream\Plugin\DataStream\DataStreamType\Basic->storageSave() (line 422 of /opt/drupal/web/profiles/farm/modules/core/data_stream/src/Plugin/DataStream/DataStreamType/Basic.php) 

To Reproduce

TBD

Expected behavior

farmOS should return a 422 Unprocessable Content response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions