Skip to content

fix: emit task process type in release YAML for cf run-task support#1324

Open
stokpop wants to merge 5 commits into
cloudfoundry:mainfrom
stokpop:fix/cf-task-command-presence
Open

fix: emit task process type in release YAML for cf run-task support#1324
stokpop wants to merge 5 commits into
cloudfoundry:mainfrom
stokpop:fix/cf-task-command-presence

Conversation

@stokpop

@stokpop stokpop commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cf run-task failed with "command presence FAILED" on Go buildpack v5
    while working on Ruby buildpack v4.77.0
  • Root cause: release YAML only declared web process type; Ruby declares
    both web and task with the same command
  • Fix: add task to default_process_types in writeReleaseYaml()
  • Escape single quotes in command via YAML '' doubling (Copilot review)
  • Fix import ordering in test file to match gofmt convention (Copilot review)
  • Add test for YAML single-quote escaping (TDD, fails before fix)
  • Add test using regexp assertion (robust against command values containing
    web: or task: substrings); single finalize.Run() call
  • Add docs: CF task usage in container-spring_boot.md (with cross-reference)
    and container-java_main.md (PropertiesLauncher pattern, --env CF CLI v7+)
  • Fix stale Ruby/rake references in integration README and debugging guide
  • Use portable sed in debugging guide; replace broken single-quoted alias
    with a shell function (Copilot review)

Test plan

  • go test ./src/java/... passes
  • YAML single-quote escaping verified by unit test (yaml.Unmarshal round-trip)
  • cf run-task without --command works on app staged with Go buildpack
  • cf run-task --env JAVA_OPTS="-Dloader.main=..." works with PropertiesLauncher

The two unchecked items require manual CF verification. The Switchblade
integration test framework has no task API, so these cannot be automated
in the current test suite. The unit test for writeReleaseYaml verifies
the YAML output is correct; runtime behavior needs a live CF environment.

Upstream issue: #1323

Ruby buildpack v4 declares both web and task in default_process_types.
Go buildpack only declared web, causing cf run-task to fail with
"command presence FAILED" when no --command is given.

Add task process type with same command as web, matching Ruby behaviour.
Add docs for CF task usage including PropertiesLauncher pattern.

Closes cloudfoundry#1323

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the finalize phase to emit a task process type in the Cloud Foundry release YAML (alongside web) so cf run-task works without requiring an explicit --command, aligning behavior with other buildpacks.

Changes:

  • Emit both web and task under default_process_types with identical commands in writeReleaseYaml().
  • Add tests asserting both process types are present and (intended to be) command-identical.
  • Add documentation describing CF task usage and the PropertiesLauncher/-Dloader.main pattern.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/java/finalize/finalize.go Adds task to default_process_types in generated release YAML.
src/java/finalize/finalize_test.go Adds/updates tests to validate task emission and command equivalence.
docs/container-spring_boot.md Documents CF task behavior and runtime main-class override guidance for Spring Boot apps.
docs/container-java_main.md Documents CF task behavior and PropertiesLauncher/-Dloader.main override guidance for Java Main container.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/java/finalize/finalize_test.go Outdated
Comment thread docs/container-spring_boot.md Outdated
stokpop added 2 commits June 21, 2026 18:02
- Replace fragile YAML string-splitting test with regexp-based assertion
- Combine two separate finalize.Run() calls into one test
- Simplify CF task section in spring_boot doc: remove misplaced
  PropertiesLauncher example, add cross-reference to java_main doc
- Expand CF task section in java_main doc: add PropertiesLauncher
  pattern with correct --env flag (CF CLI v7+)
…ing guide

- Replace `bundle exec rake package` with `./scripts/package.sh`
- Remove Ruby install requirement from local debugging section
- Replace `ruby -e yaml` YAML parser with `grep -oP` in release command examples

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread src/java/finalize/finalize.go Outdated
Comment thread src/java/finalize/finalize_test.go
Comment thread docs/debugging-the-buildpack.md Outdated
Comment thread docs/debugging-the-buildpack.md Outdated
- sort imports stdlib-first in finalize_test.go per gofmt convention
- add test: YAML single-quote escaping (TDD, fails before fix)
- escape single quotes in release YAML command; YAML single-quoted
  scalars require ' doubled as '' or the scalar terminates early
- replace grep -oP (PCRE, not available on macOS/BSD grep) with
  portable sed in debugging guide
- replace broken single-quoted alias for release() with a shell
  function; single quotes cannot nest inside single-quoted strings

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread docs/debugging-the-buildpack.md Outdated
Comment thread docs/debugging-the-buildpack.md Outdated
…ands

sed extraction outputs YAML-escaped '' verbatim; add s/''/'/g unescape.
Replace broken s| exec|| (matched nothing for javaexec commands) with
s/exec // which removes first occurrence, handling both bare
`exec $DEPS_DIR/...` and memcalc prefix `... && exec $DEPS_DIR/...`.
Combine both substitutions into one sed call.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment on lines +248 to +257
Describe("Release YAML", func() {
BeforeEach(func() {
os.Setenv("JBP_CONFIG_JAVA_MAIN", "{java_main_class: com.example.App}")
finalizer.JREName = "OpenJDK"
finalizer.ContainerName = "Java Main"
})

AfterEach(func() {
os.Unsetenv("JBP_CONFIG_JAVA_MAIN")
})
Comment thread src/integration/README.md
Comment on lines 24 to +30
First, create a buildpack zip file:

```bash
bundle exec rake package
./scripts/package.sh
```

This will create a file like `java-buildpack-v4.x.x.zip` in the project root.
This will create `build/buildpack.zip` in the project root.
Comment on lines +32 to +36
To run a task with a different main class (batch job, migration, etc.), set `java_main_class` to Spring Boot's `PropertiesLauncher` at staging time:

```yaml
env:
JBP_CONFIG_JAVA_MAIN: '{java_main_class: "org.springframework.boot.loader.launch.PropertiesLauncher"}'
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