fix(deployment): skip secret lookup for plain build variables

This commit is contained in:
Andras Bacsai
2026-09-25 07:53:04 +02:00
parent 19744f9c26
commit 65365752d7
2 changed files with 42 additions and 1 deletions
+6 -1
View File
@@ -1449,10 +1449,15 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
* Replace {{vault.KEY}} references with values from the configured secret
* manager source. Missing keys fail the deployment with a
* list — changing the source never re-checks references, so this is the
* moment problems surface.
* moment problems surface. Values without references are returned as-is
* and never fetch secrets.
*/
private function substitute_remote_secrets(string $value, string $envKey): string
{
if (! RemoteSecretReferences::containsReference($value)) {
return $value;
}
$secrets = $this->remote_secrets();
$missing = RemoteSecretReferences::missingKeys($value, $secrets);
@@ -1031,6 +1031,42 @@ it('injects raw escaped remote secrets into Dockerfile args and hashes the same
'preview' => [99, true],
]);
it('injects Dockerfile args for plain build-time variables without a secret manager source', function (int $pullRequestId, bool $isPreview) {
[$application, $server] = makeDeploymentControlVarFixture();
createApplicationEnvironmentVariable($application, [
'key' => 'APP_ENV',
'value' => 'production',
'is_preview' => $isPreview,
'is_runtime' => false,
'is_buildtime' => true,
]);
[$job, $reflection] = makeControlVarFilteringJob($application, $server, [
'pull_request_id' => $pullRequestId,
'saved_outputs' => [
'dockerfile' => "FROM php:8.4-cli\nRUN php -v",
],
]);
invokeDeploymentJobMethod($job, $reflection, 'add_build_env_variables_to_dockerfile');
$expectedHash = invokeDeploymentJobMethod(
$job,
$reflection,
'generate_secrets_hash',
collect(['APP_ENV' => escapeBashEnvValue('production')]),
);
expect($job->writtenDockerfile)
->toContain('ARG APP_ENV')
->toContain("ARG COOLIFY_BUILD_SECRETS_HASH={$expectedHash}");
expect(readDeploymentJobProperty($job, $reflection, 'remote_secrets_cache'))->toBeNull();
})->with([
'production' => [0, false],
'preview' => [99, true],
]);
it('builds railpack variables from generic buildtime vars railpack vars and coolify vars only', function () {
[$application, $server] = makeDeploymentControlVarFixture([
'build_pack' => 'railpack',