Skip to content

fix(generate): send native-deployment required_contexts as a JSON array - #646

Merged
joshua-temple merged 2 commits into
mainfrom
fix/native-deploy-required-contexts
Jul 20, 2026
Merged

fix(generate): send native-deployment required_contexts as a JSON array#646
joshua-temple merged 2 commits into
mainfrom
fix/native-deploy-required-contexts

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

The native GitHub Deployments create step passed required_contexts via gh api --raw-field required_contexts='[]'. --raw-field (and --field) always transmit the value as a scalar string, so GitHub received the literal "[]" and rejected the create with HTTP 422: For 'properties/required_contexts', "[]" is not an array or null. The Deployment was never created, and the follow-on in_progress/status calls then 404'd on an empty deployment id.

The step is gated to real GitHub (server_url == 'https://github.com') and non-dry-run, so act/gitea and the non-native lanes never exercised it. The live fleet (cascade-example-dryrun lane) caught it on the seed-dev orchestrate, a real non-dry-run run.

Fix

Assemble the create-deployment request body as JSON and pipe it via gh api --input - so required_contexts is a real, explicit empty array:

deployment_id=$(printf '{"ref":"%s","environment":"%s","auto_merge":false,"required_contexts":[],"auto_inactive":false}' "${{ github.sha }}" "$ENV_NAME" \
  | gh api repos/${{ github.repository }}/deployments \
    --method POST \
    --input - \
    --jq '.id')

The explicit [] is preserved deliberately: it means the deployment is not gated on any status contexts. Omitting the field would instead make GitHub apply the repository's default required contexts, a different and potentially blocking behavior. The in_progress and status steps are unchanged; they were only 404'ing because the create failed.

Verification

  • New generator test TestNativeDeployments_RequiredContextsIsJSONArray (red before, green after): asserts the string form required_contexts='[]' is gone and a real "required_contexts":[] array plus --input - are emitted.
  • Emitted shell verified with bash -n; the JSON body verified to parse with a real empty array.
  • e2e scenario 31-native-deployments updated to assert the JSON-body create step and a not_contains guard against the rejected string form.
  • go build, go test (3655 pass), go test -race, golangci-lint run all clean; e2e module builds and vets clean.

The real-GitHub 422 is only provable on the live fleet; cascade-example-dryrun is the runtime proof.

The native GitHub Deployments create step passed required_contexts via
gh api --raw-field, which always transmits a scalar string. GitHub
received the literal "[]" and rejected the create with HTTP 422 ("is
not an array or null"), so the Deployment was never created and the
in_progress/status calls then 404'd on an empty id. The path is gated to
real GitHub and non-dry-run, so act/gitea and non-native lanes never
exercised it.

Assemble the create-deployment request body as JSON and pipe it via
gh api --input - so required_contexts is a real, explicit empty array.
The explicit [] means the deployment is not gated on any status
contexts; omitting the field would instead apply the repository's
default required contexts, a different and potentially blocking
behavior, so the empty-array intent is preserved.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
The native-deployment create step now carries auto_inactive in the JSON
request body ("auto_inactive":<bool>) rather than a gh api --field
key=value flag. Scenario 57 still asserted the old auto_inactive=<bool>
form for both components, so its per-component deployment-reporting step
failed. Point the api/web contains and not_contains assertions at the
JSON-body form and refresh the prose that described the old shape.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit 82d7a67 into main Jul 20, 2026
21 checks passed
@joshua-temple
joshua-temple deleted the fix/native-deploy-required-contexts branch July 20, 2026 14:41
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