fix(plugins): quote path env vars in service commands so spaces in project dir work - #2960
Open
mikeland73 wants to merge 1 commit into
Open
fix(plugins): quote path env vars in service commands so spaces in project dir work#2960mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
…oject dir work
Several builtin plugins reference an absolute project path in their
process-compose service command without wrapping it in double quotes:
| Plugin | command (before) |
| --- | --- |
| apache | apachectl start -f $HTTPD_CONFDIR/httpd.conf ...; tail -f $HTTPD_ERROR_LOG_FILE |
| caddy | caddy run --config=$CADDY_CONFIG |
| php | php-fpm -y {{ .DevboxDir }}/php-fpm.conf --nodaemonize |
| redis | redis-server $REDIS_CONF --port $REDIS_PORT |
| valkey | valkey-server $VALKEY_CONF --port $VALKEY_PORT |
These variables/templates expand to the project's absolute path (for
example $CADDY_CONFIG -> "{{ .DevboxDir }}/Caddyfile"), so an unquoted
reference is word-split by the shell whenever the project directory
contains a space and the service fails to start. This is the same class
of bug as the init_hook fix in #2876, now applied to service commands.
Wrap each path reference in double quotes, matching the pattern the
postgresql plugin already uses (`-k "$PGHOST"`). Ports and other
non-path values are left unquoted. The affected plugins' version fields
are bumped, consistent with how prior plugin behavior changes are
versioned.
Adds plugins/service_command_quoting_test.go, which scans every builtin
plugin's process-compose.yaml and asserts that templated paths and known
path-bearing env vars in service commands are quoted. It fails on the old
(unquoted) content and passes on the fix.
Fixes #2631
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2631.
Several builtin plugins reference an absolute project path in their process-compose service command without wrapping it in double quotes:
apacheapachectl start -f $HTTPD_CONFDIR/httpd.conf ...,tail -f $HTTPD_ERROR_LOG_FILE,tail -f $HTTPD_ACCESS_LOG_FILEcaddycaddy run --config=$CADDY_CONFIGphpphp-fpm -y {{ .DevboxDir }}/php-fpm.conf --nodaemonizeredisredis-server $REDIS_CONF --port $REDIS_PORTvalkeyvalkey-server $VALKEY_CONF --port $VALKEY_PORTEach of these variables/templates expands to the project's absolute path (for example
$CADDY_CONFIG→{{ .DevboxDir }}/Caddyfile,$REDIS_CONF→{{ .DevboxDir }}/redis.conf). An unquoted reference is word-split by the shell whenever the project directory contains a space, so the service fails to start. This is the same class of bug as theinit_hookfix in #2876 — now applied to the plugin service commands that run underdevbox services.Fix
Wrap each path reference in double quotes, matching the pattern the
postgresqlplugin already uses (pg_isready -p "${PGPORT:-5432}"and-k "$PGHOST"). Ports and other non-path values are left unquoted. After the fix, e.g.:The affected plugins'
versionfields are bumped, consistent with how prior plugin behavior changes are versioned.The
mariadb,mysql, andnginxplugins have the same unquoted-path pattern in their service commands, but they currently have other in-flight PRs touching those exact files (#2906, #2911, #2909). They were intentionally left out of this PR to avoid conflicts and can be quoted in those PRs or a small follow-up.How was it tested?
plugins/service_command_quoting_test.go, which scans every builtin plugin'sprocess-compose.yamland asserts that templated paths ({{ ... }}) and known path-bearing env vars in service commands are quoted. It reuses the shell-quoting model from the existinginit_hook_quoting_test.go. Verified it fails on the old (unquoted) content and passes on the fix.go test ./plugins/ ./internal/plugin/,go vet ./plugins/, andgofmtare clean.cc @arent-groebner — thanks for the report.
Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
Generated by Claude Code