Skip to content

fix: preserve hyphenated values in custom Docker run options parser#9497

Open
jeongkichang wants to merge 1 commit intocoollabsio:nextfrom
jeongkichang:fix/docker-run-options-hyphenated-values
Open

fix: preserve hyphenated values in custom Docker run options parser#9497
jeongkichang wants to merge 1 commit intocoollabsio:nextfrom
jeongkichang:fix/docker-run-options-hyphenated-values

Conversation

@jeongkichang
Copy link
Copy Markdown

Changes

The regex in convertDockerRunToCompose() (bootstrap/helpers/docker.php:994) used [^\s-]+ for the value capture group, which excluded hyphens from matched values. This caused options like --security-opt no-new-privileges:true to be truncated to just "no", producing invalid security-opt: "no" on deployment.

Changed the value capture group from ([^\s-]+)? to ((?!--)[^\s]+)? — hyphens within values are now preserved while --flag boundaries are still correctly detected via negative lookahead.

Issues

Category

  • Bug fix
  • Improvement
  • New feature
  • Adding new one click service
  • Fixing or updating existing one click service

Preview

N/A — backend logic change, no UI changes.

AI Assistance

  • AI was used (please describe below)

If AI was used:

  • Tools used: Claude Code (root cause analysis, regex verification, test generation)
  • How extensively: AI assisted with regex debugging and test case generation. Fix approach was derived from the issue's root cause analysis.

Testing

./vendor/bin/pest tests/Feature/DockerCustomCommandsTest.php
# 27 passed (32 assertions) — 22 existing + 5 new

New test cases:

  1. --security-opt no-new-privileges:true (space syntax)
  2. --security-opt=no-new-privileges:true (equals syntax)
  3. --security-opt apparmor:unconfined (non-hyphenated value, regression check)
  4. --cap-drop ALL --security-opt no-new-privileges:true (combined options)
  5. --sysctl net.ipv4.ip-forward=1 (another hyphenated value option)

Contributor Agreement

Important

  • I have read and understood the contributor guidelines. If I have failed to follow any guideline, I understand that this PR may be closed without review.
  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate.
  • I have tested all the changes thoroughly with a local development instance of Coolify and I am confident that they will work as expected when a maintainer tests them.

The regex in convertDockerRunToCompose() used [^\s-]+ for the value
capture group, which excluded hyphens from matched values. This caused
options like --security-opt no-new-privileges:true to be truncated to
just "no", resulting in deployment failures.

Change the value capture group from ([^\s-]+)? to ((?!--)[^\s]+)? so
hyphens within values are preserved while --flag boundaries are still
correctly detected via negative lookahead.
@ShadowArcanist
Copy link
Copy Markdown
Member

Can you share the steps to test this without running those test files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants