Skip to content

enhancement: harden dispatch-to-contribs.yml: validate version and use --raw-field #1722

Closed

Description

@jakelorocco
  1. The version is not validated before being written to $GITHUB_OUTPUT

The "Resolve version" step writes the version straight to the step output file:

echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

On a workflow_dispatch run, VERSION comes from free-text input. $GITHUB_OUTPUT treats every line as a separate key=value output, so a value with a newline (e.g. 1.2.3\nfoo=bar) would create extra step outputs. Nothing currently reads any output other than version, so this has no impact today. It is still unvalidated input going into a file the runner parses.

  1. gh api --field reads files when the value starts with @

The dispatch step uses --field (-F):

--field "client_payload[version]=${VERSION}"

-F is gh's typed flag. It turns true/false/null/numbers into JSON types, and if the value starts with @, gh reads the named file and sends its contents. A manual run with version @/some/path would send that file from the runner to mellea-contribs in the dispatch payload. A version is always a plain string, so -f/--raw-field is the correct flag.

Proposed change

  - name: Resolve version
    if: env.SKIP != 'true'
    id: version
    env:
      INPUT_VERSION: ${{ github.event.inputs.version }}
    run: |
      if [ -n "${INPUT_VERSION}" ]; then
        VERSION="${INPUT_VERSION}"
      else
        VERSION="${GITHUB_REF#refs/tags/v}"
      fi
      if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
        echo "::error::Invalid version '${VERSION}'; expected X.Y.Z"
        exit 1
      fi
      echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
      echo "Dispatching mellea-released event to contribs with version=${VERSION}"

  - name: Dispatch to mellea-contribs
    if: env.SKIP != 'true'
    env:
      GH_TOKEN: ${{ steps.app-token.outputs.token }}
      VERSION: ${{ steps.version.outputs.version }}
    run: |
      gh api repos/generative-computing/mellea-contribs/dispatches \
        --method POST \
        --raw-field event_type=mellea-released \
        --raw-field "client_payload[version]=${VERSION}"

Notes:

  • The workflow only dispatches for stable releases (pre-releases are skipped), so the regex accepts strict X.Y.Z. If manual recovery runs ever need pre-release or post-release versions (e.g. 1.2.3rc1, 1.2.3.post1), the pattern needs widening. The safety property is that it is anchored and contains no newlines, @, or quotes.
  • Validation also catches mistakes in manual runs, like a leading v (v1.2.3) or trailing whitespace, before they reach contribs.
  • Switching to --raw-field doesn't change the payload for valid versions. 1.2.3 was already sent as a string.

Acceptance criteria

  • A manual run with an invalid version (e.g. v1.2.3, @foo, an empty string) fails at "Resolve version" with a clear error.
  • A release with a stable tag vX.Y.Z still dispatches client_payload.version = "X.Y.Z" to mellea-contribs.
  • zizmor stays clean on the workflow.

Activity

  1. added
    p2
    chore
    on Oct 8, 2026
  2. added theissue type on Oct 8, 2026
  3. jakelorocco commented on Oct 8, 2026

    @jakelorocco
    ContributorAuthor

    This is claude generated issue. I didn't have time validate everything / drive this through cicd. I think there might be other spots where these fixes could be cross-applied to other of our actions. It's a follow-up to #1717.

  4. skritosss commented on Oct 11, 2026

    @skritosss
    Contributor

    Can I take this one? The changes are ready and checked. I'll open a PR once you confirm.

  5. jakelorocco commented on Oct 12, 2026

    @jakelorocco
    ContributorAuthor

    Hi @skritosss, thanks for offering! Yes, we are happy to take a look at your PR / contribution. It might be a bit harder to work on this one since it involves github actions and you are an external contributor; but we'd still be happy to review and help merge any contributions.

  6. added a commit that references this issue on Oct 13, 2026
    2ed5d33
  7. added a commit that references this issue on Nov 5, 2026
    b1812bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

chorep2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions