fix(ci): resolve HTTP 422 on homebrew-tap dispatch#41
Merged
Conversation
The repository_dispatch API call was sending client_payload as a JSON string instead of a nested object because gh api --raw-field (-f) always serialises values as strings. Changed to --input - with a heredoc that produces properly nested JSON. Also removed continue-on-error so future failures are visible, moved github.ref_name into an env var for security hardening, and added an id to the step.
The version tests were hardcoding VERSION as "0.1.0-dev" which breaks whenever version-bump.yml updates the constant. Changed: - version_test.ts: assert VERSION matches semver-or-dev pattern (/^\d+\.\d+\.\d+(-dev)?$/) instead of exact equality - cli/mod_test.ts: compare cmd.getVersion() against imported VERSION constant instead of hardcoded string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes the repository_dispatch API call to AniTrend/homebrew-tap that fails with HTTP 422 on every release tag push.
Root cause
gh api -f client_payload='{"version":"${{ github.ref_name }}"}'sendsclient_payloadas a JSON string because-f(--raw-field) always serializes values as strings. GitHub's API expects a nested JSON object.Broken (HTTP 422):
{"event_type": "stackctl-release", "client_payload": "{\"version\":\"v0.0.1\"}"}Fixed:
{"event_type": "stackctl-release", "client_payload": {"version": "v0.0.1"}}Changes
-fflags with--input -heredoc producing properly nested JSONgithub.ref_nametoenv:variable for security hardeningcontinue-on-error: trueso future failures are visibleid: dispatch-homebrewto the stepEvidence
Error from run 29265882314: