Events API returning warnings (and so invalid JSON)

Forum for questions and support relating to 1.33.x development only.
Locked
c128
Posts: 88
Joined: Sat Sep 14, 2013 3:36 pm

Events API returning warnings (and so invalid JSON)

Post by c128 »

Hi,

Probably doing something silly here, but when querying the events API for a single event I'm getting returned a warning in the response.

Here's an example for https://<zoneminder_domain>/zm/api/events/141020.json :

Code: Select all

Warning (2): filesize(): stat failed for /var/cache/zoneminder/events///141020-video.mp4 [APP/Model/Event.php, line 139]
{ "event": { "Event": { "Id": "141020", "MonitorId": "1", "StorageId": "1", "Name": "Event- 141020", "Cause": "Linked", "StartTime": "2019-03-27 13:40:19", "EndTime": "2019-03-27 13:40:30", "Width": "1920", "Height": "1080", "Length": "11.39", "Frames": "112", "AlarmFrames": "65", "DefaultVideo": "141020-video.mp4", "SaveJPEGs": "0", "TotScore": "3250", "AvgScore": "50", "MaxScore": "50", "Archived": "0", "Videoed": "0", "Uploaded": 
<snip>
The actual JSON returned that follows seems valid, but obviously that "141020-video.mp4" file doesn't exist at the location in the warning (looks like some of the sub-directories aren't populated?) and the response as a whole isn't valid JSON to parse.

More verbose output from the link in a browser:

Code: Select all

  public function fileSize($event) {
    $storage = $this->Storage->findById($event['StorageId']);
    return filesize($storage['Storage']['Path'].'/'.$this->Relative_Path($event).'/'.$event['DefaultVideo']);
filesize - [internal], line ??
Event::fileSize() - APP/Model/Event.php, line 139
EventsController::view() - APP/Controller/EventsController.php, line 132
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 491
AppController::invokeAction() - APP/Plugin/Crud/Lib/CrudControllerTrait.php, line 31
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 193
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 167
[main] - APP/webroot/index.php, line 107
I'm running the latest master Zoneminder from the Ubuntu PPA - h.264 passthrough.

Any ideas?

Thanks.
c128
Posts: 88
Joined: Sat Sep 14, 2013 3:36 pm

Re: Events API returning warnings (and so invalid JSON)

Post by c128 »

As an update to this - just noticed that zmNinja isn't able to play events against my server either, so I guess it's related? Other functionality/API calls seem unaffected.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Events API returning warnings (and so invalid JSON)

Post by asker »

I recall getting this error a while back and it was something that Isaac fixed. It is entirely possible that the bug got re-introduced if you are on the latest master. If you are not, it may be worth updating.

Either case, you can catch up with Isaac on slack and ask him.

And yes, this is also why zmNinja will not work.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
c128
Posts: 88
Joined: Sat Sep 14, 2013 3:36 pm

Re: Events API returning warnings (and so invalid JSON)

Post by c128 »

Thanks - I'm on the latest master (at least in packaged form, from the PPA).

I think the error a while back, from searching these forums, might have been caused by something else (albeit with a similar outcome, in terms of what appears in the response, so possibly related).

The zmNinja issue I'm not so worried about, but I was looking into a script to process events - I've worked around it for now, by removing the "junk" at the start of the response to then load the valid JSON that still follows it.
Locked