Skip to content

Import-input arrays are stringified as Go-slice [a b] instead of JSON, breaking jq --argjson consumers #29076

@danielmeppiel

Description

@danielmeppiel

Summary

When a shared workflow's run: step references a list-typed import-input via ${{ github.aw.import-inputs.X }}, gh-aw substitutes the value at compile time using Go's default slice formatter (fmt.Sprint), which produces [a b] (space-separated, no quotes) instead of valid JSON. This is fine for echo but breaks any consumer that expects JSON, including the very common pattern of feeding the value to jq --argjson.

There is currently no documented escape hatch (e.g. ${{ toJSON(github.aw.import-inputs.X) }} is not resolved at compile time -- it's preserved as a runtime expression that GH Actions can't evaluate, since github.aw.* doesn't exist at runtime).

Repro

shared/foo.md:

---
import-schema:
  packages:
    type: array
    items:
      type: string
on: workflow_call
jobs:
  show:
    runs-on: ubuntu-latest
    steps:
      - env:
          PKGS: ${{ github.aw.import-inputs.packages }}
        run: |
          printf 'env value: %s\n' "$PKGS"
          echo "$PKGS" | jq --argjson p "$PKGS" '.'
---

caller.md:

---
on: push
imports:
  - uses: shared/foo.md
    with:
      packages:
        - microsoft/apm#main
        - github/awesome-copilot/skills/foo
---

After gh aw compile caller:

env:
  PKGS: "[microsoft/apm#main github/awesome-copilot/skills/foo]"
env value: [microsoft/apm#main github/awesome-copilot/skills/foo]
jq: invalid JSON text passed to --argjson
##[error]Process completed with exit code 2.

Reproduced with gh aw v0.71.1. Behaviour identical on v0.68.3.

Expected

Either:

  1. Substitute import-input arrays as JSON (["a","b"]). This matches the schema (type: array) and Just Works for both echo and jq.
  2. Expose a compile-time JSON helper, e.g. ${{ jsonInputs.packages }} or make ${{ toJSON(github.aw.import-inputs.packages) }} resolvable at compile time.

Why this matters

We hit this in microsoft/apm's shared workflow that fans out APM packages into a credential-group matrix using jq --argjson packages .... Every PR-review-panel and triage-panel run failed in apm-prep until we added a Bash+Python repair shim that detects the Go-slice format and rewrites it as JSON before jq sees it (microsoft/apm#1031 follow-up). This shim is purely a workaround -- a one-line compiler change would let every shared-workflow author treat import-input arrays as JSON natively.

Happy to send a PR if you can point me at the substitution code path.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions