From 1e48c56d63f6186945dc9dfbbd3d0d1a3c27f8cc Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 17 May 2026 09:56:33 +0000 Subject: [PATCH] feat(builds): log user build command in deployment build logs When a Site or Function build command references an environment variable (e.g. `flutter build web --dart-define=KEY=$GOOGLE_MAPS_API_KEY`) and the variable is misspelled or unset, bash silently expands it to an empty string. Build logs previously did not surface the build command, so users had no signal that the expansion was happening. Echo the unexpanded, user-typed `buildCommands` value at the top of the build log. `$` is escaped to `\$` before `escapeshellarg` so the outer bash wrapper does not expand variables in the log line, and the user sees exactly what they typed (e.g. `$GOOGLE_MAPS_API_KEY`). Empty `buildCommands` is skipped (no log line). Applies uniformly to Sites and Functions, since both flow through the same build worker path. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Platform/Modules/Functions/Workers/Builds.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 5aa95d3bf2..cd13ced759 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -719,7 +719,14 @@ class Builds extends Action } } - $command = 'tar -zxf /tmp/code.tar.gz -C /mnt/code && helpers/build.sh ' . \trim(\escapeshellarg($command)); + $userBuildCommand = $deployment->getAttribute('buildCommands', ''); + $logCommand = ''; + if (! empty($userBuildCommand)) { + $escapedForLog = \str_replace('$', '\\$', $userBuildCommand); + $logCommand = 'echo ' . \escapeshellarg('Build command: ' . $escapedForLog) . ' && '; + } + + $command = $logCommand . 'tar -zxf /tmp/code.tar.gz -C /mnt/code && helpers/build.sh ' . \trim(\escapeshellarg($command)); } $response = $executor->createRuntime(