Page MenuHomeDevCentral

Null exception in api-serverslogs
Closed, ResolvedPublic

Description

[24-Apr-2019 18:40:09 UTC] PHP Fatal error:  Uncaught InvalidArgumentException: JsonMapper::map() requires first argument to be an object, NULL given. in /srv/api/servers-log/vendor/netresearch/jsonmapper/src/JsonMapper.php:126
Stack trace:
#0 /srv/api/servers-log/src/LogEntry.php(43): JsonMapper->map(NULL, Object(Nasqueron\Api\ServersLog\LogEntry))
#1 /srv/api/servers-log/src/Service.php(42): Nasqueron\Api\ServersLog\LogEntry::fromJSON(NULL)
#2 /srv/api/servers-log/src/Service.php(33): Nasqueron\Api\ServersLog\Service->put(NULL)
#3 /srv/api/servers-log/src/public/index.php(19): Nasqueron\Api\ServersLog\Service->handle()
#4 {main}

An old stacktrace, that's the last error of the log, so we've probably a better code client side, but still, the NULL value isn't handled by Service::put().

When calling the service with a PUT request, it's expected we've a json payload, or we should gracefully fail and serve an HTTP 400 error.

Event Timeline

dereckson created this task.
dereckson renamed this task from Upgrade JsonMapper in api-serverslogs to Null exception in api-serverslogs.May 21 2022, 20:30
dereckson updated the task description. (Show Details)