From a08e6692bd17b4c9ef280928b4a02c35332cfd89 Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Tue, 14 Apr 2026 11:10:11 +0200 Subject: [PATCH 1/2] webservice: get_recording_url_list error handling We need get_recording_url_list() to return an array of recordings. So when the API gives us an error message that means "there are no recordings", then we need to return an empty array (so that it matches). If the API gives us an error message that means "there was a problem when we tried to find the recordings", then we don't want to pretend that we know how many recordings there are (so we allow other exception types to bubble up). Finally, if there was no API error message, then we should have an API response that we can use. However, the code is written to assume that we know how the API response is structured. If the code is in the structure that we expect, then use it. Otherwise, we should throw our own "unexpected response structure" error message to avoid returning incorrect information. --- classes/webservice.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/classes/webservice.php b/classes/webservice.php index ed961926..7c1f6019 100644 --- a/classes/webservice.php +++ b/classes/webservice.php @@ -1135,9 +1135,22 @@ public function get_recording_url_list($meetingid) { // Classic: recording:read:admin. // Granular: cloud_recording:read:list_recording_files:admin. $url = 'meetings/' . $this->encode_uuid($meetingid) . '/recordings'; - $response = $this->make_call($url); - if (!empty($response->recording_files)) { + try { + $response = $this->make_call($url); + } catch (not_found_exception $e) { + // If the meeting was not found (1001) or there are no recordings (3301), return an empty array. + return []; + } + + if (empty($response->recording_files)) { + $recordingcount = (int) $response->recording_count; + $audiocount = count($response->participant_audio_files); + if ($recordingcount !== $audiocount) { + // If there are no recording files and the recording count does not match, throw an exception. + throw new bad_request_exception("recording_count: $recordingcount != participant_audio_files: $audiocount", 400); + } + } else { foreach ($response->recording_files as $recording) { $url = $recording->play_url ?? $recording->download_url ?? null; if (!empty($url) && isset($allowedrecordingtypes[$recording->file_type])) { From c29996768a0dbec618b9a660e4c1f3e8eae5423c Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Tue, 14 Apr 2026 11:27:02 +0200 Subject: [PATCH 2/2] webservice: warn if recording_count does not exist --- classes/webservice.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/webservice.php b/classes/webservice.php index 7c1f6019..e8b253db 100644 --- a/classes/webservice.php +++ b/classes/webservice.php @@ -1144,6 +1144,10 @@ public function get_recording_url_list($meetingid) { } if (empty($response->recording_files)) { + if (!isset($response->recording_count)) { + throw new bad_request_exception('recording_count: undefined', 400); + } + $recordingcount = (int) $response->recording_count; $audiocount = count($response->participant_audio_files); if ($recordingcount !== $audiocount) {