From f8db55c1578cce9de6647ff87e493a37f92a2949 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 5 Aug 2026 11:14:41 +0000 Subject: [PATCH] fix: tolerate already-deleted configs (storage.configuration.notFound) during ownerless workspace cleanup Co-Authored-By: olena.marchuk --- .../DeleteOrganizationOwnerlessWorkspaces.php | 15 +++++++++++++-- .../Console/Command/DeleteOwnerlessWorkspaces.php | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php b/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php index 562c17a..593b3ac 100644 --- a/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php +++ b/src/Keboola/Console/Command/DeleteOrganizationOwnerlessWorkspaces.php @@ -182,7 +182,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $components->deleteConfiguration($session['componentId'], $session['configurationId']); $components->deleteConfiguration($session['componentId'], $session['configurationId']); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // The configuration may already be gone (notFound) or refuse permanent + // deletion (cannotDeleteConfiguration). Either way its editor session can + // still linger, so clean it up and continue instead of aborting the run. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } $editorClient->deleteSession($session['id']); @@ -273,7 +279,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // Already trashed/purged (notFound) or unpurgeable + // (cannotDeleteConfiguration) — nothing left to do here. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } } diff --git a/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php b/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php index cda0c99..7bb6c79 100644 --- a/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php +++ b/src/Keboola/Console/Command/DeleteOwnerlessWorkspaces.php @@ -128,7 +128,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $components->deleteConfiguration($componentId, $configurationId); $components->deleteConfiguration($componentId, $configurationId); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // The configuration may already be gone (notFound) or refuse permanent + // deletion (cannotDeleteConfiguration). Either way its editor session can + // still linger, so clean it up and continue instead of aborting the run. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } $editorClient->deleteSession($sessionId); @@ -209,7 +215,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); $storageComponents->deleteConfiguration('keboola.sandboxes', $app->getConfigId()); } catch (StorageClientException $e) { - if ($e->getStringCode() !== 'storage.components.cannotDeleteConfiguration') { + // Already trashed/purged (notFound) or unpurgeable + // (cannotDeleteConfiguration) — nothing left to do here. + if (!in_array($e->getStringCode(), [ + 'storage.configuration.notFound', + 'storage.components.cannotDeleteConfiguration', + ], true)) { throw $e; } }