Skip to content

Capture staging logs on failure in CF API v3#121

Merged
ramonskie merged 1 commit intomainfrom
v3-stage-fail-logs
Dec 5, 2025
Merged

Capture staging logs on failure in CF API v3#121
ramonskie merged 1 commit intomainfrom
v3-stage-fail-logs

Conversation

@ramonskie
Copy link
Contributor

In CF API v3, when 'cf start' fails during staging, the buildpack staging logs are not automatically captured in stdout/stderr. This causes test failures when trying to assert against staging output, as the logs buffer only contains setup phase output (org/space creation, routes, etc.).

This change updates Stage.Run() to automatically fetch recent logs using 'cf logs --recent' when staging fails, and appends them to the main logs buffer before returning the error. This makes staging failure logs available to tests transparently, without requiring workarounds in individual buildpack test suites.

Benefits:

  • Tests can assert against staging logs in both API v2 and v3
  • Eliminates need for manual 'cf logs --recent' workarounds
  • Consistent behavior across all buildpacks using switchblade

In CF API v3, when 'cf start' fails during staging, the buildpack
staging logs are not automatically captured in stdout/stderr. This
causes test failures when trying to assert against staging output,
as the logs buffer only contains setup phase output (org/space
creation, routes, etc.).

This change updates Stage.Run() to automatically fetch recent logs
using 'cf logs --recent' when staging fails, and appends them to
the main logs buffer before returning the error. This makes staging
failure logs available to tests transparently, without requiring
workarounds in individual buildpack test suites.

Benefits:
- Tests can assert against staging logs in both API v2 and v3
- Eliminates need for manual 'cf logs --recent' workarounds
- Consistent behavior across all buildpacks using switchblade
Copy link
Contributor

@ivanovac ivanovac left a comment

Choose a reason for hiding this comment

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

LGTM

@ramonskie ramonskie merged commit f452557 into main Dec 5, 2025
2 checks passed
@ramonskie ramonskie deleted the v3-stage-fail-logs branch December 5, 2025 15:12
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