fix(railpack): query buildtime env vars directly instead of via computed attribute

Replace `railpack_environment_variables_collection()` helper (which returned
pre-filtered Eloquent attribute collections) with inline queries on
`environment_variables()` / `environment_variables_preview()` filtered by
`is_buildtime`. This ensures Railpack build variables are sourced from the
same query path as the rest of the deployment pipeline and avoids relying on
a now-removed accessor that silently included all railpack vars regardless of
build context.
This commit is contained in:
Andras Bacsai committed 2026-04-30 16:38:58 +02:00
1 parent ec71d33f5e
commit ace643d3d8
2 files changed
+23 -16

No files matched your search

+15 -10
View File
@@ -2483,15 +2483,6 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
return $variables;
}
private function railpack_environment_variables_collection(): Collection
{
if ($this->pull_request_id === 0) {
return $this->application->railpack_environment_variables;
}
return $this->application->railpack_environment_variables_preview;
}
private function normalize_resolved_build_variable_value(EnvironmentVariable $environmentVariable): ?string
{
$resolvedValue = $environmentVariable->getResolvedValueWithServer($this->mainServer);
@@ -2506,9 +2497,23 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
return $resolvedValue;
}
/**
* All buildtime variables that must reach the Railpack build.
*
* Railpack's BuildKit frontend treats every `--env` passed to `railpack prepare`
* as a build secret entry in the generated plan, then pairs it with `--secret id=,env=`
* on `docker buildx build`. Because Railpack's schema disallows top-level `variables`
* (unlike Nixpacks, which bakes variables into the plan), this `--env` → `--secret`
* channel is the only way user-defined buildtime variables become available to
* commands declared with `useSecrets: true`.
*/
private function railpack_build_variables(): Collection
{
$variables = $this->railpack_environment_variables_collection()
$envCollection = $this->pull_request_id === 0
? $this->application->environment_variables()->where('is_buildtime', true)->get()
: $this->application->environment_variables_preview()->where('is_buildtime', true)->get();
$variables = $envCollection
->mapWithKeys(function (EnvironmentVariable $environmentVariable) {
$value = $this->normalize_resolved_build_variable_value($environmentVariable);
if (is_null($value) || $value === '') {