Skip to content

Commit ce614eb

Browse files
fix: throw when mittwald_api_client token resolves to an empty string
1 parent 00389d4 commit ce614eb

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Database/Manager/MittwaldApi.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,17 @@ private function initClient(): MittwaldAPIV2Client
196196
throw new \RuntimeException('Deployer variable "mittwald_project_id" is not set or empty.');
197197
}
198198

199-
$this->client = MittwaldAPIV2Client::newWithToken(get('mittwald_api_client'));
199+
$apiToken = (string) get('mittwald_api_client');
200+
if ('' === trim($apiToken)) {
201+
throw new \RuntimeException(
202+
'Deployer variable "mittwald_api_client" resolved to an empty string. '
203+
. 'If this value comes from a CI/CD variable, check that it is not restricted '
204+
. 'to protected branches/refs (e.g. GitLab "Protect variable"), since feature '
205+
. 'branches are typically unprotected.'
206+
);
207+
}
208+
209+
$this->client = MittwaldAPIV2Client::newWithToken($apiToken);
200210
return $this->client;
201211
}
202212

0 commit comments

Comments
 (0)