@htekdev/actions-debugger 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/errors/permissions-auth/deploy-pages-missing-permissions.yml +144 -0
- package/errors/permissions-auth/fine-grained-pat-actions-scope-missing.yml +128 -0
- package/errors/triggers/repository-dispatch-event-type-mismatch.yml +116 -0
- package/errors/triggers/workflow-call-required-input-not-supplied.yml +115 -0
- package/errors/triggers/workflow-dispatch-required-input-api-bypass.yml +114 -0
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
id: permissions-auth-009
|
|
2
|
+
title: "actions/deploy-pages Fails 403 — Missing pages: write or id-token: write Permissions"
|
|
3
|
+
category: permissions-auth
|
|
4
|
+
severity: error
|
|
5
|
+
tags:
|
|
6
|
+
- deploy-pages
|
|
7
|
+
- pages
|
|
8
|
+
- permissions
|
|
9
|
+
- id-token
|
|
10
|
+
- oidc
|
|
11
|
+
- github-token
|
|
12
|
+
- 403
|
|
13
|
+
patterns:
|
|
14
|
+
- regex: "Failed to create deployment.*status: 403.*pages: write"
|
|
15
|
+
flags: "i"
|
|
16
|
+
- regex: "Resource not accessible by integration"
|
|
17
|
+
flags: "i"
|
|
18
|
+
- regex: "Fetching artifact metadata failed.*Resource not accessible by integration"
|
|
19
|
+
flags: "i"
|
|
20
|
+
- regex: "Error: Error: Failed to create deployment \\(status: 403\\)"
|
|
21
|
+
flags: "i"
|
|
22
|
+
error_messages:
|
|
23
|
+
- "Error: Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages or Actions? Please re-run the deployment at a later time."
|
|
24
|
+
- "Error: HttpError: Resource not accessible by integration"
|
|
25
|
+
- "Error: Error: Failed to create deployment (status: 403) with build version abc123. Ensure GITHUB_TOKEN has permission \"pages: write\"."
|
|
26
|
+
- "Creating Pages deployment failed"
|
|
27
|
+
root_cause: |
|
|
28
|
+
`actions/deploy-pages` uses the GitHub Pages REST API, which requires an OIDC-issued
|
|
29
|
+
JWT token for authentication. This imposes three distinct permissions that must all be
|
|
30
|
+
present on the **deploy job** (not the build job):
|
|
31
|
+
|
|
32
|
+
1. `pages: write` — allows the GITHUB_TOKEN to create and update GitHub Pages deployments.
|
|
33
|
+
2. `id-token: write` — allows the runner to request an OIDC JWT from GitHub's token
|
|
34
|
+
endpoint. Without this, `deploy-pages` cannot obtain the token used to authenticate
|
|
35
|
+
the Pages API call, resulting in the misleading "Resource not accessible by integration"
|
|
36
|
+
HTTP 403 error.
|
|
37
|
+
3. `contents: read` — required to read the uploaded artifact. Often already set by
|
|
38
|
+
inheritance but must be explicit when a workflow-level `permissions:` block restricts
|
|
39
|
+
all tokens to read-only.
|
|
40
|
+
|
|
41
|
+
**Why this is confusing:**
|
|
42
|
+
- The error message says "Resource not accessible by integration" which looks like a generic
|
|
43
|
+
API permission problem, not a missing `id-token` scope.
|
|
44
|
+
- The `pages: write` permission alone is insufficient — `id-token: write` is equally
|
|
45
|
+
required and its absence produces the exact same error.
|
|
46
|
+
- Permissions set at the **workflow level** do not automatically apply to jobs that override
|
|
47
|
+
them. The deploy job must declare its own `permissions:` block.
|
|
48
|
+
- The artifact upload (via `actions/upload-pages-artifact`) happens in a SEPARATE job from
|
|
49
|
+
the deploy — permissions for upload and deploy must be set independently.
|
|
50
|
+
|
|
51
|
+
**Source:** Confirmed in `actions/deploy-pages` issues #285, #286 (Dec 2023) — over 16
|
|
52
|
+
reactions and widespread community impact.
|
|
53
|
+
fix: |
|
|
54
|
+
Add all three required permissions to the deploy job. The build job that runs
|
|
55
|
+
`upload-pages-artifact` does not need these permissions, but the deploy job does.
|
|
56
|
+
|
|
57
|
+
Also verify that GitHub Pages is enabled for the repository under
|
|
58
|
+
Settings → Pages → Source → "GitHub Actions".
|
|
59
|
+
fix_code:
|
|
60
|
+
- language: yaml
|
|
61
|
+
label: "Correct two-job Pages deployment workflow with required permissions"
|
|
62
|
+
code: |
|
|
63
|
+
name: Deploy GitHub Pages
|
|
64
|
+
|
|
65
|
+
on:
|
|
66
|
+
push:
|
|
67
|
+
branches: [main]
|
|
68
|
+
|
|
69
|
+
# Deny all permissions at workflow level; grant explicitly per job
|
|
70
|
+
permissions:
|
|
71
|
+
contents: read
|
|
72
|
+
|
|
73
|
+
jobs:
|
|
74
|
+
build:
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
steps:
|
|
77
|
+
- uses: actions/checkout@v4
|
|
78
|
+
|
|
79
|
+
- name: Build site
|
|
80
|
+
run: npm run build # outputs to ./dist
|
|
81
|
+
|
|
82
|
+
- name: Upload Pages artifact
|
|
83
|
+
uses: actions/upload-pages-artifact@v3
|
|
84
|
+
with:
|
|
85
|
+
path: ./dist
|
|
86
|
+
|
|
87
|
+
deploy:
|
|
88
|
+
needs: build
|
|
89
|
+
runs-on: ubuntu-latest
|
|
90
|
+
permissions:
|
|
91
|
+
pages: write # ← Required: create/update Pages deployment
|
|
92
|
+
id-token: write # ← Required: obtain OIDC JWT for Pages API auth
|
|
93
|
+
contents: read # ← Required: read the uploaded artifact
|
|
94
|
+
environment:
|
|
95
|
+
name: github-pages
|
|
96
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
97
|
+
steps:
|
|
98
|
+
- name: Deploy to GitHub Pages
|
|
99
|
+
id: deployment
|
|
100
|
+
uses: actions/deploy-pages@v4
|
|
101
|
+
- language: yaml
|
|
102
|
+
label: "Single-job variant — all permissions in one job"
|
|
103
|
+
code: |
|
|
104
|
+
name: Deploy Pages (single job)
|
|
105
|
+
|
|
106
|
+
on:
|
|
107
|
+
push:
|
|
108
|
+
branches: [main]
|
|
109
|
+
|
|
110
|
+
jobs:
|
|
111
|
+
deploy:
|
|
112
|
+
runs-on: ubuntu-latest
|
|
113
|
+
permissions:
|
|
114
|
+
pages: write
|
|
115
|
+
id-token: write
|
|
116
|
+
contents: read
|
|
117
|
+
environment:
|
|
118
|
+
name: github-pages
|
|
119
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
120
|
+
steps:
|
|
121
|
+
- uses: actions/checkout@v4
|
|
122
|
+
- name: Build
|
|
123
|
+
run: npm run build
|
|
124
|
+
- uses: actions/upload-pages-artifact@v3
|
|
125
|
+
with:
|
|
126
|
+
path: ./dist
|
|
127
|
+
- id: deployment
|
|
128
|
+
uses: actions/deploy-pages@v4
|
|
129
|
+
prevention:
|
|
130
|
+
- "Always set `pages: write`, `id-token: write`, and `contents: read` on the deploy job — not the build job and not only at the workflow level."
|
|
131
|
+
- "Confirm GitHub Pages is enabled under repository Settings → Pages → Source → 'GitHub Actions' before running the workflow."
|
|
132
|
+
- "When using a workflow-level `permissions:` block that restricts defaults, remember job-level permissions do not inherit write scopes — they must be re-declared."
|
|
133
|
+
- "The `environment: github-pages` block is required for the Pages API to create a deployment — do not omit it."
|
|
134
|
+
docs:
|
|
135
|
+
- url: "https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow"
|
|
136
|
+
label: "GitHub Docs: Publishing GitHub Pages with Actions"
|
|
137
|
+
- url: "https://github.com/actions/deploy-pages"
|
|
138
|
+
label: "actions/deploy-pages — official action repository"
|
|
139
|
+
- url: "https://github.com/actions/deploy-pages/issues/285"
|
|
140
|
+
label: "actions/deploy-pages #285: Failing to fetch artifact metadata since 4.0.0"
|
|
141
|
+
- url: "https://github.com/actions/deploy-pages/issues/286"
|
|
142
|
+
label: "actions/deploy-pages #286: Bump to V4 broke the deploy step"
|
|
143
|
+
- url: "https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect"
|
|
144
|
+
label: "GitHub Docs: Security hardening with OpenID Connect"
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
id: permissions-auth-010
|
|
2
|
+
title: "Fine-Grained PAT Missing Actions Permission — Workflow Dispatch and API Calls Fail 403"
|
|
3
|
+
category: permissions-auth
|
|
4
|
+
severity: error
|
|
5
|
+
tags:
|
|
6
|
+
- fine-grained-pat
|
|
7
|
+
- pat
|
|
8
|
+
- personal-access-token
|
|
9
|
+
- actions
|
|
10
|
+
- workflow-dispatch
|
|
11
|
+
- 403
|
|
12
|
+
- api
|
|
13
|
+
patterns:
|
|
14
|
+
- regex: "HTTP 403.*fine.?grained.*token"
|
|
15
|
+
flags: "i"
|
|
16
|
+
- regex: "Resource not accessible by integration"
|
|
17
|
+
flags: "i"
|
|
18
|
+
- regex: "Must have admin rights to Repository\\."
|
|
19
|
+
flags: "i"
|
|
20
|
+
- regex: "403.*workflow.*dispatch"
|
|
21
|
+
flags: "i"
|
|
22
|
+
error_messages:
|
|
23
|
+
- "HTTP 403: {\"message\":\"Resource not accessible by integration\",\"documentation_url\":\"https://docs.github.com/rest/actions/workflows\"}"
|
|
24
|
+
- "Error: error making HTTP request: 403 Resource not accessible by integration"
|
|
25
|
+
- "gh: Could not run workflow: HTTP 422 Unprocessable Entity"
|
|
26
|
+
- "RequestError [HttpError]: Resource not accessible by integration"
|
|
27
|
+
root_cause: |
|
|
28
|
+
GitHub fine-grained personal access tokens (introduced 2022, GA 2023) do NOT include
|
|
29
|
+
the "Actions" permission scope by default when created. This is different from classic
|
|
30
|
+
PATs where the `repo` scope implicitly granted access to Actions APIs.
|
|
31
|
+
|
|
32
|
+
When a fine-grained PAT is used to:
|
|
33
|
+
- Trigger workflows via REST API (`POST /repos/{owner}/{repo}/actions/workflows/{id}/dispatches`)
|
|
34
|
+
- List or cancel workflow runs
|
|
35
|
+
- Download workflow run logs
|
|
36
|
+
- Use `gh workflow run` / `gh run list` with the PAT as `GH_TOKEN`
|
|
37
|
+
|
|
38
|
+
...the API returns HTTP 403 "Resource not accessible by integration" because the
|
|
39
|
+
fine-grained token lacks the explicit `Actions: read` or `Actions: write` permission.
|
|
40
|
+
|
|
41
|
+
**Why this affects more users over time:**
|
|
42
|
+
- GitHub is progressively deprecating classic PATs in favor of fine-grained PATs.
|
|
43
|
+
- Organization policies can require fine-grained PATs only, blocking classic PAT usage.
|
|
44
|
+
- Automation pipelines that worked with classic `repo`-scoped PATs silently break when
|
|
45
|
+
migrated to fine-grained PATs if the Actions permission is not explicitly added.
|
|
46
|
+
- The error message "Resource not accessible by integration" is the same as the one
|
|
47
|
+
shown for missing `GITHUB_TOKEN` scopes, making diagnosis harder.
|
|
48
|
+
|
|
49
|
+
**Required permissions on the fine-grained PAT by use case:**
|
|
50
|
+
| Use case | Required permission |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Trigger workflow (`workflow_dispatch`) | Actions: write |
|
|
53
|
+
| Cancel / re-run workflow run | Actions: write |
|
|
54
|
+
| List workflow runs / jobs | Actions: read |
|
|
55
|
+
| Download workflow run logs | Actions: read |
|
|
56
|
+
| Read workflow YAML definitions | Actions: read |
|
|
57
|
+
fix: |
|
|
58
|
+
Regenerate or edit the fine-grained PAT and add the **Actions** permission with the
|
|
59
|
+
appropriate access level:
|
|
60
|
+
|
|
61
|
+
- **Read-only** — for listing runs, reading logs, checking run status.
|
|
62
|
+
- **Read and write** — for dispatching workflows, cancelling runs, re-triggering jobs.
|
|
63
|
+
|
|
64
|
+
Navigate to: GitHub → Settings → Developer Settings → Personal access tokens →
|
|
65
|
+
Fine-grained tokens → (select token) → Permissions → Repository permissions →
|
|
66
|
+
Actions → set to "Read and write".
|
|
67
|
+
|
|
68
|
+
If the repository is in an organization, also ensure the organization has not restricted
|
|
69
|
+
fine-grained PAT usage to specific resources that exclude this repository.
|
|
70
|
+
fix_code:
|
|
71
|
+
- language: yaml
|
|
72
|
+
label: "Using a fine-grained PAT with Actions permission to trigger a workflow"
|
|
73
|
+
code: |
|
|
74
|
+
# Store the fine-grained PAT as a repository secret: DEPLOY_PAT
|
|
75
|
+
# The PAT must have: Actions: write, Contents: read (minimum)
|
|
76
|
+
|
|
77
|
+
name: Trigger Deployment
|
|
78
|
+
|
|
79
|
+
on:
|
|
80
|
+
workflow_dispatch:
|
|
81
|
+
|
|
82
|
+
jobs:
|
|
83
|
+
trigger:
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
steps:
|
|
86
|
+
- name: Dispatch downstream workflow
|
|
87
|
+
run: |
|
|
88
|
+
gh workflow run deploy.yml \
|
|
89
|
+
-f environment=production \
|
|
90
|
+
--repo org/downstream-repo
|
|
91
|
+
env:
|
|
92
|
+
GH_TOKEN: ${{ secrets.DEPLOY_PAT }} # Fine-grained PAT with Actions: write
|
|
93
|
+
- language: yaml
|
|
94
|
+
label: "Required PAT permissions checklist for common Actions API uses"
|
|
95
|
+
code: |
|
|
96
|
+
# Fine-grained PAT permission requirements:
|
|
97
|
+
#
|
|
98
|
+
# Trigger workflow dispatch → Actions: Write
|
|
99
|
+
# Cancel a workflow run → Actions: Write
|
|
100
|
+
# Re-run failed jobs → Actions: Write
|
|
101
|
+
# List workflow runs → Actions: Read
|
|
102
|
+
# Download run logs → Actions: Read
|
|
103
|
+
# Get workflow definition → Actions: Read
|
|
104
|
+
# Approve environment deployment → Actions: Write + Environments: Write
|
|
105
|
+
#
|
|
106
|
+
# Classic PAT 'repo' scope covers all of the above implicitly.
|
|
107
|
+
# Fine-grained PATs require explicit opt-in per permission category.
|
|
108
|
+
|
|
109
|
+
# To check if your PAT has the right permissions:
|
|
110
|
+
- name: Verify PAT has Actions permission
|
|
111
|
+
run: |
|
|
112
|
+
gh api /repos/${{ github.repository }}/actions/workflows \
|
|
113
|
+
--jq '.total_count'
|
|
114
|
+
env:
|
|
115
|
+
GH_TOKEN: ${{ secrets.DEPLOY_PAT }} # Returns 403 if Actions: read is missing
|
|
116
|
+
prevention:
|
|
117
|
+
- "When migrating from classic PATs to fine-grained PATs, explicitly audit which permission categories the classic `repo` scope was implicitly covering and add each one."
|
|
118
|
+
- "Add `Actions: read` at minimum to any fine-grained PAT that will be used in GitHub Actions pipelines, even for read-only operations."
|
|
119
|
+
- "Store fine-grained PATs as org-level or repository secrets and add a comment documenting which permissions the PAT requires."
|
|
120
|
+
- "Use a dedicated machine account (bot user) for automation PATs so permissions can be audited independently of individual developer accounts."
|
|
121
|
+
- "If an organization policy requires fine-grained PATs, update all automation onboarding docs to include the Actions permission explicitly."
|
|
122
|
+
docs:
|
|
123
|
+
- url: "https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token"
|
|
124
|
+
label: "GitHub Docs: Creating a fine-grained personal access token"
|
|
125
|
+
- url: "https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event"
|
|
126
|
+
label: "REST API: Create a workflow dispatch event"
|
|
127
|
+
- url: "https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/setting-a-personal-access-token-policy-for-your-organization"
|
|
128
|
+
label: "GitHub Docs: PAT policy for organizations"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
id: triggers-010
|
|
2
|
+
title: "repository_dispatch Event Type Not in types: Filter — Workflow Silently Skipped"
|
|
3
|
+
category: triggers
|
|
4
|
+
severity: silent-failure
|
|
5
|
+
tags:
|
|
6
|
+
- repository_dispatch
|
|
7
|
+
- event-type
|
|
8
|
+
- types-filter
|
|
9
|
+
- triggers
|
|
10
|
+
- api
|
|
11
|
+
- silent
|
|
12
|
+
patterns:
|
|
13
|
+
- regex: "repository_dispatch"
|
|
14
|
+
flags: "i"
|
|
15
|
+
- regex: "types:\\s*\\[.*\\]"
|
|
16
|
+
flags: "i"
|
|
17
|
+
- regex: "client_payload"
|
|
18
|
+
flags: "i"
|
|
19
|
+
error_messages:
|
|
20
|
+
- "No runs found for workflow"
|
|
21
|
+
- "Workflow not triggered by repository_dispatch event"
|
|
22
|
+
root_cause: |
|
|
23
|
+
A `repository_dispatch` workflow only fires when the dispatched `event_type` value
|
|
24
|
+
matches one of the values in the `types:` filter. If the event type sent via the API
|
|
25
|
+
does not match, GitHub silently drops it — no error, no notification, the workflow simply
|
|
26
|
+
never starts.
|
|
27
|
+
|
|
28
|
+
**Common failure scenarios:**
|
|
29
|
+
|
|
30
|
+
1. **Typo or case mismatch**: `event_type: "Deploy_Staging"` dispatched but workflow
|
|
31
|
+
has `types: [deploy_staging]` (underscore vs case sensitivity). Event types are
|
|
32
|
+
case-sensitive.
|
|
33
|
+
|
|
34
|
+
2. **Omitting the types: filter entirely — workflow fires for ALL events** (opposite
|
|
35
|
+
problem): Without a `types:` filter, the workflow runs for every `repository_dispatch`
|
|
36
|
+
event, including internal automation events not intended to trigger it.
|
|
37
|
+
|
|
38
|
+
3. **API payload uses wrong field name**: The REST API requires the `event_type` field
|
|
39
|
+
under the JSON body. Some clients accidentally nest it differently or omit it entirely,
|
|
40
|
+
causing the dispatch to use the default empty event type which matches nothing.
|
|
41
|
+
|
|
42
|
+
4. **Cross-workflow automation chain**: Workflow A dispatches event type `build-complete`.
|
|
43
|
+
Workflow B listens for `build_complete` (underscore). The chain silently breaks with no
|
|
44
|
+
logs in either workflow.
|
|
45
|
+
|
|
46
|
+
**API payload shape:**
|
|
47
|
+
```
|
|
48
|
+
POST /repos/{owner}/{repo}/dispatches
|
|
49
|
+
{
|
|
50
|
+
"event_type": "deploy_staging", ← Must exactly match types: filter
|
|
51
|
+
"client_payload": { ... }
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
fix: |
|
|
55
|
+
Verify that the `event_type` string in the API POST body matches exactly (case-sensitive)
|
|
56
|
+
one of the values declared in the workflow's `types:` filter.
|
|
57
|
+
|
|
58
|
+
To debug: add a catch-all workflow with no `types:` filter (matches all repository_dispatch
|
|
59
|
+
events) to confirm the event is arriving at all, then compare the `github.event.action`
|
|
60
|
+
value to what your workflow expects.
|
|
61
|
+
fix_code:
|
|
62
|
+
- language: yaml
|
|
63
|
+
label: "Workflow with correctly declared repository_dispatch types filter"
|
|
64
|
+
code: |
|
|
65
|
+
on:
|
|
66
|
+
repository_dispatch:
|
|
67
|
+
types:
|
|
68
|
+
- deploy_staging # ← Must match event_type exactly (case-sensitive)
|
|
69
|
+
- deploy_production
|
|
70
|
+
- run_smoke_tests
|
|
71
|
+
|
|
72
|
+
jobs:
|
|
73
|
+
deploy:
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/checkout@v4
|
|
77
|
+
- name: Show dispatched event
|
|
78
|
+
run: |
|
|
79
|
+
echo "Event: ${{ github.event.action }}"
|
|
80
|
+
echo "Payload: ${{ toJSON(github.event.client_payload) }}"
|
|
81
|
+
- language: yaml
|
|
82
|
+
label: "Debugging workflow — catch ALL repository_dispatch events"
|
|
83
|
+
code: |
|
|
84
|
+
# Temporarily add this workflow to diagnose missing dispatches
|
|
85
|
+
on:
|
|
86
|
+
repository_dispatch: # No types: filter = receives everything
|
|
87
|
+
|
|
88
|
+
jobs:
|
|
89
|
+
debug:
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
steps:
|
|
92
|
+
- name: Log event details
|
|
93
|
+
run: |
|
|
94
|
+
echo "event_type / action: ${{ github.event.action }}"
|
|
95
|
+
echo "client_payload: ${{ toJSON(github.event.client_payload) }}"
|
|
96
|
+
- language: yaml
|
|
97
|
+
label: "Dispatching via REST API — correct payload structure"
|
|
98
|
+
code: |
|
|
99
|
+
# Using gh api to dispatch correctly
|
|
100
|
+
gh api \
|
|
101
|
+
--method POST \
|
|
102
|
+
-H "Accept: application/vnd.github+json" \
|
|
103
|
+
/repos/ORG/REPO/dispatches \
|
|
104
|
+
-f event_type="deploy_staging" \ # ← Matches types: [deploy_staging]
|
|
105
|
+
-F client_payload='{"version":"v1.2.3","env":"staging"}'
|
|
106
|
+
prevention:
|
|
107
|
+
- "Treat `event_type` values as constants — define them in a shared location (e.g., a constants file or workflow comment) used by both the dispatcher and the listener."
|
|
108
|
+
- "Add an `echo` step that logs `github.event.action` at the start of every repository_dispatch workflow to confirm the correct event type was received."
|
|
109
|
+
- "Use a catch-all debug workflow (no `types:` filter) when setting up a new dispatch chain for the first time."
|
|
110
|
+
- "Avoid changing event type strings in active automation chains — add new types instead of renaming existing ones."
|
|
111
|
+
- "Event types are case-sensitive — stick to snake_case by convention to avoid case mismatch bugs."
|
|
112
|
+
docs:
|
|
113
|
+
- url: "https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#repository_dispatch"
|
|
114
|
+
label: "GitHub Actions: repository_dispatch event"
|
|
115
|
+
- url: "https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event"
|
|
116
|
+
label: "REST API: Create a repository dispatch event"
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
id: triggers-009
|
|
2
|
+
title: "Reusable Workflow Required Input Not Supplied — workflow_call Fails at Runtime"
|
|
3
|
+
category: triggers
|
|
4
|
+
severity: error
|
|
5
|
+
tags:
|
|
6
|
+
- workflow_call
|
|
7
|
+
- reusable-workflow
|
|
8
|
+
- inputs
|
|
9
|
+
- required
|
|
10
|
+
- validation
|
|
11
|
+
- caller
|
|
12
|
+
patterns:
|
|
13
|
+
- regex: "Input required and not supplied:\\s*\\w+"
|
|
14
|
+
flags: "i"
|
|
15
|
+
- regex: "Required input '\\w+' not provided"
|
|
16
|
+
flags: "i"
|
|
17
|
+
- regex: "Error: Input required and not supplied"
|
|
18
|
+
flags: "i"
|
|
19
|
+
error_messages:
|
|
20
|
+
- "Error: Input required and not supplied: deploy_env"
|
|
21
|
+
- "Input required and not supplied: version"
|
|
22
|
+
- "Required input 'environment' not provided by caller"
|
|
23
|
+
root_cause: |
|
|
24
|
+
Unlike `workflow_dispatch` (which treats `required: true` as UI-only), the GitHub Actions
|
|
25
|
+
runner DOES validate required inputs for `on.workflow_call` reusable workflows. If a caller
|
|
26
|
+
workflow invokes a reusable workflow without passing a declared required input, the runner
|
|
27
|
+
emits `Error: Input required and not supplied: {input_name}` and fails the job immediately.
|
|
28
|
+
|
|
29
|
+
**Common scenarios:**
|
|
30
|
+
1. **Adding a required input to an existing reusable workflow** without updating all callers.
|
|
31
|
+
Callers that worked before immediately break because the new required input is missing.
|
|
32
|
+
|
|
33
|
+
2. **Calling a reusable workflow from a matrix job** where one matrix variation doesn't
|
|
34
|
+
apply the needed input conditionally.
|
|
35
|
+
|
|
36
|
+
3. **Caller passes the input only under certain conditions** (via `if:`) — when the condition
|
|
37
|
+
is false, the input is omitted entirely rather than being passed as an empty string.
|
|
38
|
+
|
|
39
|
+
4. **Typo in the input name** — caller passes `deploy-env` but the reusable workflow expects
|
|
40
|
+
`deploy_env` (hyphens vs underscores). The declared input is not satisfied.
|
|
41
|
+
|
|
42
|
+
**Note:** The error fires at job evaluation time, not step execution time, so the entire job
|
|
43
|
+
is skipped rather than reaching the failing step.
|
|
44
|
+
fix: |
|
|
45
|
+
Ensure every caller workflow passes all required inputs declared in the reusable workflow's
|
|
46
|
+
`on.workflow_call.inputs` block.
|
|
47
|
+
|
|
48
|
+
When adding a new required input to a reusable workflow, update all callers before merging.
|
|
49
|
+
Use `required: false` with a default value if backward compatibility must be preserved.
|
|
50
|
+
|
|
51
|
+
If the input is only sometimes needed, declare it as `required: false` and check it
|
|
52
|
+
at runtime inside the reusable workflow using an early-exit validation step.
|
|
53
|
+
fix_code:
|
|
54
|
+
- language: yaml
|
|
55
|
+
label: "Reusable workflow with required input declaration"
|
|
56
|
+
code: |
|
|
57
|
+
# .github/workflows/deploy-reusable.yml
|
|
58
|
+
on:
|
|
59
|
+
workflow_call:
|
|
60
|
+
inputs:
|
|
61
|
+
environment:
|
|
62
|
+
description: "Target environment"
|
|
63
|
+
required: true # Runner enforces this for all callers
|
|
64
|
+
type: string
|
|
65
|
+
version:
|
|
66
|
+
description: "Version tag"
|
|
67
|
+
required: false
|
|
68
|
+
default: "latest"
|
|
69
|
+
type: string
|
|
70
|
+
|
|
71
|
+
jobs:
|
|
72
|
+
deploy:
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v4
|
|
76
|
+
- run: ./deploy.sh "${{ inputs.environment }}" "${{ inputs.version }}"
|
|
77
|
+
- language: yaml
|
|
78
|
+
label: "Caller workflow — always pass all required inputs"
|
|
79
|
+
code: |
|
|
80
|
+
# .github/workflows/release.yml
|
|
81
|
+
on:
|
|
82
|
+
push:
|
|
83
|
+
tags: ["v*"]
|
|
84
|
+
|
|
85
|
+
jobs:
|
|
86
|
+
deploy:
|
|
87
|
+
uses: ./.github/workflows/deploy-reusable.yml
|
|
88
|
+
with:
|
|
89
|
+
environment: production # ✅ Required input provided
|
|
90
|
+
version: ${{ github.ref_name }}
|
|
91
|
+
- language: yaml
|
|
92
|
+
label: "Backward-compatible: change required to optional with default"
|
|
93
|
+
code: |
|
|
94
|
+
# When adding new inputs to existing reusable workflows, use required: false
|
|
95
|
+
# with a default to avoid breaking existing callers.
|
|
96
|
+
on:
|
|
97
|
+
workflow_call:
|
|
98
|
+
inputs:
|
|
99
|
+
environment:
|
|
100
|
+
required: true
|
|
101
|
+
type: string
|
|
102
|
+
notify_slack: # New input — safe to add with required: false
|
|
103
|
+
required: false
|
|
104
|
+
default: "false"
|
|
105
|
+
type: string
|
|
106
|
+
prevention:
|
|
107
|
+
- "When adding a new `required: true` input to a reusable workflow, search all callers with `grep -r 'uses:.*deploy-reusable'` and update them simultaneously."
|
|
108
|
+
- "Prefer `required: false` with a sensible default when backward compatibility matters — validate the value inside the reusable workflow if needed."
|
|
109
|
+
- "Use consistent naming conventions (all underscores or all hyphens) for input names to avoid typo-related mismatches between callers and the called workflow."
|
|
110
|
+
- "Test reusable workflow changes in a draft PR that also updates all callers."
|
|
111
|
+
docs:
|
|
112
|
+
- url: "https://docs.github.com/en/actions/sharing-automations/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow"
|
|
113
|
+
label: "GitHub Docs: Inputs in reusable workflows"
|
|
114
|
+
- url: "https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_call"
|
|
115
|
+
label: "GitHub Actions: workflow_call event"
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
id: triggers-008
|
|
2
|
+
title: "workflow_dispatch required: true Silently Bypassed via REST API"
|
|
3
|
+
category: triggers
|
|
4
|
+
severity: silent-failure
|
|
5
|
+
tags:
|
|
6
|
+
- workflow_dispatch
|
|
7
|
+
- inputs
|
|
8
|
+
- required
|
|
9
|
+
- rest-api
|
|
10
|
+
- gh-cli
|
|
11
|
+
- validation
|
|
12
|
+
patterns:
|
|
13
|
+
- regex: "workflow_dispatch.*inputs.*required.*true"
|
|
14
|
+
flags: "i"
|
|
15
|
+
- regex: "inputs\\.\\w+.*==.*''"
|
|
16
|
+
flags: "i"
|
|
17
|
+
error_messages:
|
|
18
|
+
- "Input required and not supplied: {input_name}"
|
|
19
|
+
root_cause: |
|
|
20
|
+
The `required: true` flag on `workflow_dispatch` inputs is enforced **only in the GitHub
|
|
21
|
+
UI** — it renders the field as mandatory in the "Run workflow" dialog. When a workflow
|
|
22
|
+
is triggered via the REST API (`POST /repos/{owner}/{repo}/actions/workflows/{id}/dispatches`)
|
|
23
|
+
or `gh workflow run`, the `required` flag is NOT validated server-side. The workflow is
|
|
24
|
+
dispatched and runs with the input set to an empty string `""` rather than the declared
|
|
25
|
+
default or an error.
|
|
26
|
+
|
|
27
|
+
This creates a subtle silent failure: developers assume `required: true` prevents invalid
|
|
28
|
+
automation, but any API caller can trigger the workflow with no inputs at all. Steps that
|
|
29
|
+
depend on the input receive an empty string without any indication something is wrong.
|
|
30
|
+
|
|
31
|
+
**Contrast with `workflow_call` (reusable workflows):** Required inputs on `on.workflow_call`
|
|
32
|
+
ARE validated by the runner — a missing required input produces `Error: Input required and
|
|
33
|
+
not supplied: {input_name}` and the job fails immediately. This inconsistency between the
|
|
34
|
+
two dispatch types frequently surprises developers.
|
|
35
|
+
|
|
36
|
+
**GitHub API behavior (documented):** The REST API returns HTTP 204 (success) even when
|
|
37
|
+
required inputs are omitted. This is by design — GitHub treats `required: true` as a UI
|
|
38
|
+
hint only.
|
|
39
|
+
fix: |
|
|
40
|
+
Treat `required: true` as UI-only and add explicit runtime validation at the top of your
|
|
41
|
+
workflow or job for any input that is truly required.
|
|
42
|
+
|
|
43
|
+
Use an `if:` guard or a validation step that fails the workflow immediately with a clear
|
|
44
|
+
error message when a required input is empty:
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
- name: Validate required inputs
|
|
48
|
+
run: |
|
|
49
|
+
if [ -z "${{ inputs.environment }}" ]; then
|
|
50
|
+
echo "::error::Input 'environment' is required but was not provided."
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For `gh workflow run` dispatch, newer versions of the CLI (v2.40+) will prompt for
|
|
56
|
+
required inputs interactively, but non-interactive (CI) invocations must pass `-f key=value`
|
|
57
|
+
explicitly.
|
|
58
|
+
fix_code:
|
|
59
|
+
- language: yaml
|
|
60
|
+
label: "Validate required inputs at runtime with an early-exit step"
|
|
61
|
+
code: |
|
|
62
|
+
on:
|
|
63
|
+
workflow_dispatch:
|
|
64
|
+
inputs:
|
|
65
|
+
environment:
|
|
66
|
+
description: "Target environment (required)"
|
|
67
|
+
required: true
|
|
68
|
+
type: choice
|
|
69
|
+
options: [staging, production]
|
|
70
|
+
version:
|
|
71
|
+
description: "Semantic version tag to deploy (required)"
|
|
72
|
+
required: true
|
|
73
|
+
type: string
|
|
74
|
+
|
|
75
|
+
jobs:
|
|
76
|
+
deploy:
|
|
77
|
+
runs-on: ubuntu-latest
|
|
78
|
+
steps:
|
|
79
|
+
# Guard against API bypasses — required: true is UI-only
|
|
80
|
+
- name: Validate required inputs
|
|
81
|
+
run: |
|
|
82
|
+
MISSING=""
|
|
83
|
+
[ -z "${{ inputs.environment }}" ] && MISSING="$MISSING environment"
|
|
84
|
+
[ -z "${{ inputs.version }}" ] && MISSING="$MISSING version"
|
|
85
|
+
if [ -n "$MISSING" ]; then
|
|
86
|
+
echo "::error::Missing required inputs:$MISSING"
|
|
87
|
+
exit 1
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
- uses: actions/checkout@v4
|
|
91
|
+
- name: Deploy
|
|
92
|
+
run: ./deploy.sh "${{ inputs.environment }}" "${{ inputs.version }}"
|
|
93
|
+
- language: yaml
|
|
94
|
+
label: "Triggering with gh workflow run — always pass required inputs explicitly"
|
|
95
|
+
code: |
|
|
96
|
+
# ✅ Correct: pass all required inputs
|
|
97
|
+
gh workflow run deploy.yml \
|
|
98
|
+
-f environment=staging \
|
|
99
|
+
-f version=v1.2.3
|
|
100
|
+
|
|
101
|
+
# ❌ Wrong: omits required inputs — workflow still runs, inputs are empty strings
|
|
102
|
+
gh workflow run deploy.yml
|
|
103
|
+
prevention:
|
|
104
|
+
- "Never rely on `required: true` alone for server-side enforcement — add a runtime validation step."
|
|
105
|
+
- "Document in your workflow that inputs must be passed explicitly when triggering via API or CI pipelines."
|
|
106
|
+
- "For security-critical workflows (deploy, release), use a job-level `if:` condition to block the entire job when an input is empty."
|
|
107
|
+
- "Consider reusable workflow (`workflow_call`) if you need server-enforced required inputs."
|
|
108
|
+
docs:
|
|
109
|
+
- url: "https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_dispatch"
|
|
110
|
+
label: "GitHub Actions: workflow_dispatch event"
|
|
111
|
+
- url: "https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event"
|
|
112
|
+
label: "REST API: Create a workflow dispatch event"
|
|
113
|
+
- url: "https://cli.github.com/manual/gh_workflow_run"
|
|
114
|
+
label: "gh workflow run — GitHub CLI manual"
|
package/package.json
CHANGED