Skip to content

fix: blueprints validate exits non-zero on invalid blueprint in non-interactive mode - #50

Open
kawacukennedy wants to merge 1 commit into
render-oss:mainfrom
kawacukennedy:fix/blueprint-validate-exit-code
Open

fix: blueprints validate exits non-zero on invalid blueprint in non-interactive mode#50
kawacukennedy wants to merge 1 commit into
render-oss:mainfrom
kawacukennedy:fix/blueprint-validate-exit-code

Conversation

@kawacukennedy

Copy link
Copy Markdown

What

render blueprints validate now exits non-zero when a Blueprint has validation errors in non-interactive modes (--output json/yaml/text). It also no longer panics if the API returns a 200 with an empty/unparseable body.

Why

This is a validate command — its primary use case is scripting and CI, where the exit code is the contract. Today:

  • Interactive mode returns "<file> has validation errors" and exits 1 (cmd/blueprintvalidate.go:201).
  • Non-interactive modes print the validation result and return nil, so render blueprints validate -o json ./bad.yaml exits 0 even when the blueprint is invalid. A CI job or script cannot tell valid from invalid.

The two paths disagree on the same command's contract. This change makes non-interactive mode match interactive mode.

How

  • After printing the result via command.PrintData, return the same "<path> has validation errors" error when result.Valid is false.
  • Guard against a 200 response with an empty body (result == nil), which previously panicked on result.Valid.

Testing

  • New tests in cmd/blueprintvalidate_test.go using an httptest server (following the logout_test.go precedent):
    • Valid blueprint succeeds in json/yaml/text modes, and the workspace ID is sent to the endpoint.
    • Invalid blueprint returns an error in all three modes while still printing the validation errors.
    • Invalid blueprint JSON output is valid JSON with "valid": false plus a non-zero exit.
    • Empty 200 response returns a clear error instead of panicking.
  • Verified end-to-end against a local mock: invalid blueprint now exits 1.
  • go test ./cmd/... ./pkg/... ./internal/... passes.
  • No new lint findings (existing lint issues in the repo are pre-existing on main).

…nteractive mode

The interactive path returns an error when a Blueprint has validation
errors, which exits non-zero. The non-interactive paths (--output
json/yaml/text) printed the validation result and returned nil, so a
script or CI job could not tell whether validation failed — the exact
case a validate command exists to catch.

Match the interactive contract: after printing the result, return the
same "has validation errors" error when result.Valid is false. Also
guard against a 200 response with an empty/unparseable body (result ==
nil) that previously panicked on result.Valid.

Adds tests covering valid/invalid blueprints across json, yaml, and
text output, the workspace ID sent to the validate endpoint, and the
empty-response guard.
@kawacukennedy
kawacukennedy force-pushed the fix/blueprint-validate-exit-code branch from 7a36e48 to 7aab3aa Compare August 13, 2026 19:38
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.

1 participant