Added WS_DEBUG_IMPORT to save invalid GUIDs responses from server.

This commit is contained in:
Abdulmhsen B. A. A
2022-04-22 03:15:50 +03:00
parent b9e053440c
commit ccd6dc147f
7 changed files with 26 additions and 1 deletions

View File

@@ -324,6 +324,7 @@ None that we are aware of.
- (string) `WS_CRON_CACHE_AT` cron expression timer. - (string) `WS_CRON_CACHE_AT` cron expression timer.
- (string) `WS_LOGS_PRUNE_AFTER` Delete logs older than specified time, set to `disable` to disable logs pruning. it - (string) `WS_LOGS_PRUNE_AFTER` Delete logs older than specified time, set to `disable` to disable logs pruning. it
follows php [strtotime](https://www.php.net/strtotime) function rules. follows php [strtotime](https://www.php.net/strtotime) function rules.
- (bool) `WS_DEBUG_IMPORT` Whether to log invalid GUID items from server in `${WS_TMP_DIR}/debug`.
# Container specific environment variables # Container specific environment variables

View File

@@ -79,6 +79,7 @@ return (function () {
]; ];
$config['debug'] = [ $config['debug'] = [
'import' => (bool)env('WS_DEBUG_IMPORT', false),
'profiler' => [ 'profiler' => [
'options' => [ 'options' => [
'save.handler' => 'file', 'save.handler' => 'file',

View File

@@ -9,4 +9,5 @@ return [
'%(tmpDir)/cache', '%(tmpDir)/cache',
'%(tmpDir)/profiler', '%(tmpDir)/profiler',
'%(tmpDir)/webhooks', '%(tmpDir)/webhooks',
'%(tmpDir)/debug',
]; ];

View File

@@ -48,6 +48,10 @@ final class PruneCommand extends Command
'path' => Config::get('tmpDir') . '/webhooks', 'path' => Config::get('tmpDir') . '/webhooks',
'filter' => '*.json', 'filter' => '*.json',
], ],
[
'path' => Config::get('tmpDir') . '/debug',
'filter' => '*.json',
],
]; ];
/** @var array<SplFileInfo> $files */ /** @var array<SplFileInfo> $files */

View File

@@ -1141,11 +1141,21 @@ class JellyfinServer implements ServerInterface
} }
if (!$this->hasSupportedIds((array)($item->ProviderIds ?? []))) { if (!$this->hasSupportedIds((array)($item->ProviderIds ?? []))) {
if (true === Config::get('debug.import')) {
$name = $this->name . '.' . ($item->Id ?? 'r' . random_int(1, PHP_INT_MAX)) . '.json';
if (!file_exists($name)) {
file_put_contents($name, json_encode($item, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
}
$this->logger->notice( $this->logger->notice(
sprintf('Ignoring %s. No valid GUIDs.', $iName), sprintf('Ignoring %s. No valid GUIDs.', $iName),
(array)($item->ProviderIds ?? []) (array)($item->ProviderIds ?? [])
); );
Data::increment($this->name, $type . '_ignored_no_supported_guid'); Data::increment($this->name, $type . '_ignored_no_supported_guid');
return; return;
} }

View File

@@ -1169,6 +1169,14 @@ class PlexServer implements ServerInterface
} }
if (!$this->hasSupportedIds($item->Guid)) { if (!$this->hasSupportedIds($item->Guid)) {
if (true === Config::get('debug.import')) {
$name = $this->name . '.' . ($item->ratingKey ?? 'r' . random_int(1, PHP_INT_MAX)) . '.json';
if (!file_exists($name)) {
file_put_contents($name, json_encode($item, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
}
$this->logger->notice(sprintf('Ignoring %s. No valid GUIDs.', $iName), $item->Guid ?? []); $this->logger->notice(sprintf('Ignoring %s. No valid GUIDs.', $iName), $item->Guid ?? []);
Data::increment($this->name, $type . '_ignored_no_supported_guid'); Data::increment($this->name, $type . '_ignored_no_supported_guid');
return; return;

View File

@@ -260,7 +260,7 @@ if (!function_exists('saveRequestPayload')) {
]; ];
@file_put_contents( @file_put_contents(
Config::get('tmpDir') . '/webhooks/' . sprintf( Config::get('tmpDir') . '/debug/' . sprintf(
'request.%s.json', 'request.%s.json',
(string)ag($request->getServerParams(), 'X_REQUEST_ID', time()) (string)ag($request->getServerParams(), 'X_REQUEST_ID', time())
), ),