Skip to content

Commit

Permalink
CLI-1293: [api:notifications:find] typeerror for sketchy notification…
Browse files Browse the repository at this point in the history
… strings (#1705)

* CLI-1293: [api:notifications:find] typeerror for sketchy notification strings

* add test

* mutation test
  • Loading branch information
danepowell authored Mar 20, 2024
1 parent 5c73afc commit fa4ee3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1233,9 +1233,14 @@ private static function getNotificationUuid(string $notification): string {
// Not a UUID, maybe a JSON object?
try {
$json = json_decode($notification, NULL, 4, JSON_THROW_ON_ERROR);
return CommandBase::getNotificationUuidFromResponse($json);
if (is_object($json)) {
return self::getNotificationUuidFromResponse($json);
}
// In rare cases, JSON can decode to a string that's a valid UUID.
self::validateUuid($json);
return $json;
}
catch (JsonException | AcquiaCliException) {
catch (JsonException | AcquiaCliException | ValidatorException) {
}

// Last chance, maybe a URL?
Expand Down
6 changes: 6 additions & 0 deletions tests/phpunit/src/Commands/App/TaskWaitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function providerTestTaskWaitCommand(): array {
}
EOT,
],
[
'"1bd3487e-71d1-4fca-a2d9-5f969b3d35c1"',
],
];
}

Expand Down Expand Up @@ -148,6 +151,9 @@ public function providerTestTaskWaitCommandWithInvalidJson(): array {
}
EOT,
],
[
'"11bd3487e-71d1-4fca-a2d9-5f969b3d35c1"',
],
];
}

Expand Down

0 comments on commit fa4ee3e

Please sign in to comment.