Skip to content

Including on.needs for custom jobs results in invalid workflow #30780

@jeffhandley

Description

@jeffhandley

According to Frontmatter Reference | GitHub Agentic Workflows, the on.needs property should allow specification of additional custom workflow jobs that pre_activation and activation should depend on.

on:
  # Explicit additional custom workflow jobs that pre_activation and activation
  # should depend on.
  # (optional)
  needs: []
    # Array of strings

When specifying this property, the pre_activation and activation jobs do gain the job in their needs lists, but the on.needs property is also emitted into the workflow, which is invalid.

repro-on-needs-bug.md

---
on:
  needs: [custom_job]
  workflow_dispatch:

jobs:
  custom_job:
    runs-on: ubuntu-slim
    steps:
      - shell: bash
        run: echo "Hello from custom_job"
---

# Repro on.needs Bug

This workflow reproduces the on.needs bug where that property is emitted into the compiled workflow, leading to a workflow syntax error.

Expected Result

name: "Repro on.needs Bug"
"on":
  workflow_dispatch:
    inputs:
      aw_context:
        default: ""
        description: Agent caller context (used internally by Agentic Workflows).
        required: false
        type: string

permissions: {}

concurrency:
  group: "gh-aw-${{ github.workflow }}"

run-name: "Repro on.needs Bug"

jobs:
  activation:
    needs:
      - custom_job
      - pre_activation
# ...
  agent:
    needs:
      - activation
      - custom_job
# ...
  pre_activation:
    needs: custom_job
# ...

Actual Result

name: "Repro on.needs Bug"
"on":
  needs:
  - custom_job
  workflow_dispatch:
    inputs:
      aw_context:
        default: ""
        description: Agent caller context (used internally by Agentic Workflows).
        required: false
        type: string

permissions: {}

concurrency:
  group: "gh-aw-${{ github.workflow }}"

run-name: "Repro on.needs Bug"

jobs:
  activation:
    needs:
      - custom_job
      - pre_activation
# ...
  agent:
    needs:
      - activation
      - custom_job
# ...
  pre_activation:
    needs: custom_job
# ...

Metadata

Metadata

Assignees

No one assigned

    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