@htekdev/actions-debugger 1.0.56 → 1.0.57

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.
@@ -0,0 +1,125 @@
1
+ id: triggers-043
2
+ title: "on.push with both branches and paths filters uses AND logic — push must match BOTH to trigger"
3
+ category: triggers
4
+ severity: silent-failure
5
+ tags:
6
+ - on.push
7
+ - branches
8
+ - paths
9
+ - filter
10
+ - and-logic
11
+ - trigger
12
+ - paths-ignore
13
+ patterns:
14
+ - regex: 'on:\s*\n\s*push:\s*\n(?:\s+.*\n)*\s+branches:'
15
+ flags: 'i'
16
+ - regex: 'push:.*branches.*paths|branches.*paths.*push'
17
+ flags: 'si'
18
+ error_messages:
19
+ - "on:\n push:\n branches:"
20
+ - "on:\n push:\n paths:"
21
+ root_cause: |
22
+ When a push trigger specifies BOTH a branches filter AND a paths filter, GitHub
23
+ Actions evaluates them using AND logic: the push event must match a listed branch
24
+ AND must include changes to a listed path. If either condition is not satisfied,
25
+ the workflow does not trigger — silently, with no log output or explanation.
26
+
27
+ Developers frequently expect OR logic: "trigger when pushing to main, OR when
28
+ any file in src/ changes." In reality, the behavior is: "trigger only when
29
+ pushing to main AND a file in src/ changed."
30
+
31
+ This means:
32
+ - A push to 'main' that only modifies 'README.md' does NOT trigger a workflow
33
+ configured with branches: [main] and paths: ['src/**']
34
+ - A push to a feature branch that modifies 'src/app.ts' does NOT trigger the
35
+ same workflow because the branch filter is not satisfied
36
+ - The workflow only runs when both conditions are simultaneously true
37
+
38
+ The same AND logic applies to other filter combinations:
39
+ - branches + tags: AND (a ref must match a branch pattern AND a tag pattern —
40
+ which is always false since a push cannot be both a branch and tag push)
41
+ - branches + paths-ignore: push must match a listed branch AND must NOT touch
42
+ any ignored path
43
+ - tags + paths: push must match a tag pattern AND include changes to listed paths
44
+
45
+ A particularly confusing case: using both on.push.branches and on.push.tags in
46
+ the same push trigger block creates an unsatisfiable AND condition (a push cannot
47
+ simultaneously target a branch AND create a tag). To trigger on either, use
48
+ two separate on: entries or separate workflow files.
49
+ fix: |
50
+ If you want OR logic (trigger on main branch OR on changes to src/), you have
51
+ two options:
52
+
53
+ Option 1 — Use only one filter and handle the other in job-level if: conditions:
54
+ Push with paths filter only, then use: if: github.ref == 'refs/heads/main'
55
+ on the job to restrict execution to main.
56
+
57
+ Option 2 — Accept that both conditions must be true (the correct model for
58
+ "only run expensive tests when the right branch AND relevant files change").
59
+
60
+ For truly independent OR triggers, use separate workflow files.
61
+ fix_code:
62
+ - language: yaml
63
+ label: "AND logic (default) — trigger only when branch AND path both match"
64
+ code: |
65
+ on:
66
+ push:
67
+ branches:
68
+ - main
69
+ - 'release/**'
70
+ paths:
71
+ - 'src/**'
72
+ - 'package.json'
73
+ # This workflow runs ONLY when:
74
+ # - Push is to 'main' or a 'release/*' branch
75
+ # AND
76
+ # - The push includes changes to src/ or package.json
77
+ # A push to main that only changes README.md will NOT trigger this workflow.
78
+ - language: yaml
79
+ label: "Separate workflow files for OR logic between independent trigger conditions"
80
+ code: |
81
+ # File 1: .github/workflows/deploy-main.yml
82
+ # Triggers on any push to main (regardless of changed paths)
83
+ on:
84
+ push:
85
+ branches:
86
+ - main
87
+
88
+ # File 2: .github/workflows/test-src.yml
89
+ # Triggers on any push that changes src/ (regardless of branch)
90
+ on:
91
+ push:
92
+ paths:
93
+ - 'src/**'
94
+ - 'tests/**'
95
+ - language: yaml
96
+ label: "Paths filter only — restrict by path in job if: conditions"
97
+ code: |
98
+ on:
99
+ push:
100
+ paths:
101
+ - 'src/**'
102
+ - 'package.json'
103
+ - 'package-lock.json'
104
+
105
+ jobs:
106
+ test:
107
+ runs-on: ubuntu-latest
108
+ # Additional branch restriction handled in job condition
109
+ if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
110
+ steps:
111
+ - uses: actions/checkout@v4
112
+ - run: npm test
113
+ prevention:
114
+ - "Read the GitHub docs note: 'If both branches and paths filters are used, the workflow will only run when both filters are satisfied'"
115
+ - "When debugging a workflow that doesn't trigger, temporarily remove one filter at a time to isolate whether the branch OR path filter is blocking the trigger"
116
+ - "Add a comment above combined branch+paths filters explicitly stating 'AND logic — both must match' to prevent future maintainers from misunderstanding"
117
+ - "Use actionlint or GitHub's workflow syntax checker which surfaces filter logic warnings"
118
+ - "Prefer paths-ignore over paths when you want 'run on everything except these files' — it's less likely to cause accidental AND-logic surprises"
119
+ docs:
120
+ - url: "https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#using-filters"
121
+ label: "GitHub Docs — Using filters with push and pull_request events"
122
+ - url: "https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#push"
123
+ label: "GitHub Docs — push event filters (branches, tags, paths)"
124
+ - url: "https://stackoverflow.com/questions/63822219/github-actions-workflow-not-triggered-with-branch-and-path-filter"
125
+ label: "Stack Overflow — Workflow not triggered with branch and path filter (highly voted)"
@@ -0,0 +1,135 @@
1
+ id: yaml-syntax-040
2
+ title: "YAML anchors and aliases (&anchor / *alias) not supported in GitHub Actions workflow files"
3
+ category: yaml-syntax
4
+ severity: error
5
+ tags:
6
+ - yaml-anchors
7
+ - yaml-aliases
8
+ - yaml-syntax
9
+ - workflow-validation
10
+ - reuse
11
+ - composite-action
12
+ patterns:
13
+ - regex: 'mapping values are not allowed in this context'
14
+ flags: 'i'
15
+ - regex: 'could not find expected.*anchor'
16
+ flags: 'i'
17
+ - regex: 'Invalid workflow file'
18
+ flags: 'i'
19
+ error_messages:
20
+ - "Invalid workflow file: .github/workflows/ci.yml"
21
+ - "mapping values are not allowed in this context"
22
+ - "could not find expected ':'"
23
+ root_cause: |
24
+ GitHub Actions uses a YAML parser that does NOT support YAML anchors (&anchor_name)
25
+ and aliases (*anchor_name). These are standard YAML 1.1 features commonly used in
26
+ Docker Compose, Kubernetes manifests, and other DevOps tooling to avoid repetition.
27
+
28
+ Developers migrating from those tools often try patterns like:
29
+
30
+ .common-steps: &common-steps
31
+ - uses: actions/checkout@v4
32
+ - run: npm ci
33
+
34
+ jobs:
35
+ build:
36
+ steps: *common-steps
37
+ test:
38
+ steps: *common-steps
39
+
40
+ GitHub's workflow validator rejects these with cryptic parse errors such as
41
+ "mapping values are not allowed in this context" or simply "Invalid workflow file"
42
+ without identifying the anchor as the cause. In some parser versions, the anchor
43
+ definition is silently ignored while the alias (*common-steps) causes a hard failure
44
+ when evaluated.
45
+
46
+ The reason: GitHub validates workflow files against a strict JSON schema and uses a
47
+ restricted YAML subset. Anchors and merge keys (<<: *anchor) are explicitly outside
48
+ the supported grammar, regardless of whether they are valid YAML 1.1 per the spec.
49
+ fix: |
50
+ Use GitHub Actions' native reuse mechanisms instead of YAML anchors:
51
+
52
+ 1. Composite actions (.github/actions/<name>/action.yml): package shared steps into
53
+ a local action and reference it with `uses: ./.github/actions/<name>` from any job.
54
+
55
+ 2. Reusable workflows (on.workflow_call): extract shared job sequences into a separate
56
+ workflow file called with `uses: ./.github/workflows/<file>.yml@<ref>`.
57
+
58
+ 3. Shared shell scripts: commit scripts to the repository and call them with `run:`.
59
+ This avoids repeating multi-line run blocks without requiring action packaging.
60
+
61
+ 4. Repository-level actions (public): publish shared logic as a public action and
62
+ reference it by `owner/repo@tag`.
63
+ fix_code:
64
+ - language: yaml
65
+ label: "Composite action for shared setup steps — .github/actions/setup/action.yml"
66
+ code: |
67
+ # .github/actions/setup/action.yml
68
+ name: Project Setup
69
+ description: Install dependencies and configure environment
70
+ inputs:
71
+ node-version:
72
+ description: Node.js version to use
73
+ default: '20'
74
+ runs:
75
+ using: composite
76
+ steps:
77
+ - uses: actions/checkout@v4
78
+ - uses: actions/setup-node@v4
79
+ with:
80
+ node-version: ${{ inputs.node-version }}
81
+ cache: npm
82
+ - run: npm ci
83
+ shell: bash
84
+ - language: yaml
85
+ label: "Calling the composite action from multiple jobs — replaces *alias pattern"
86
+ code: |
87
+ jobs:
88
+ build:
89
+ runs-on: ubuntu-latest
90
+ steps:
91
+ - uses: ./.github/actions/setup
92
+ with:
93
+ node-version: '20'
94
+ - run: npm run build
95
+
96
+ test:
97
+ runs-on: ubuntu-latest
98
+ steps:
99
+ - uses: ./.github/actions/setup
100
+ with:
101
+ node-version: '20'
102
+ - run: npm test
103
+ - language: yaml
104
+ label: "Reusable workflow for shared job sequences"
105
+ code: |
106
+ # .github/workflows/shared-ci.yml
107
+ on:
108
+ workflow_call:
109
+ inputs:
110
+ environment:
111
+ type: string
112
+ required: true
113
+ jobs:
114
+ test:
115
+ runs-on: ubuntu-latest
116
+ steps:
117
+ - uses: actions/checkout@v4
118
+ - run: npm ci && npm test
119
+ env:
120
+ APP_ENV: ${{ inputs.environment }}
121
+ prevention:
122
+ - "Do not use YAML anchors (&) or aliases (*) or merge keys (<<:) in GitHub Actions workflow files — they are not supported"
123
+ - "Use composite actions (.github/actions/<name>/action.yml) for shared step sequences across jobs"
124
+ - "Use reusable workflows (on.workflow_call) for shared job sequences across workflow files"
125
+ - "Use shared shell scripts committed to the repository for repeated run blocks"
126
+ - "Run actionlint — it explicitly flags anchor/alias syntax as unsupported in Actions workflows"
127
+ docs:
128
+ - url: "https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action"
129
+ label: "GitHub Docs — Creating a composite action"
130
+ - url: "https://docs.github.com/en/actions/sharing-automations/reusing-workflows"
131
+ label: "GitHub Docs — Reusing workflows"
132
+ - url: "https://github.com/rhysd/actionlint/blob/main/docs/checks.md"
133
+ label: "actionlint — Workflow file linting checks"
134
+ - url: "https://github.com/orgs/community/discussions/16638"
135
+ label: "GitHub Community — YAML anchors not supported in Actions workflows"
@@ -0,0 +1,147 @@
1
+ id: yaml-syntax-041
2
+ title: "env context unavailable at job-level if: conditions — evaluates empty or triggers 'Context access might be invalid' warning"
3
+ category: yaml-syntax
4
+ severity: error
5
+ tags:
6
+ - env-context
7
+ - job-conditions
8
+ - if-condition
9
+ - context-availability
10
+ - expression
11
+ - workflow-validation
12
+ patterns:
13
+ - regex: 'Context access might be invalid.*env'
14
+ flags: 'i'
15
+ - regex: 'Unexpected value.*env\.'
16
+ flags: 'i'
17
+ - regex: 'jobs\.[a-z_-]+\.if.*env\.[A-Z_]+'
18
+ flags: 'i'
19
+ error_messages:
20
+ - "Context access might be invalid: env"
21
+ - "The workflow is not valid. .github/workflows/ci.yml: Unexpected value 'env'"
22
+ root_cause: |
23
+ The `env` context in GitHub Actions is NOT available at all expression locations.
24
+ Its availability is scoped to specific parts of the workflow file.
25
+
26
+ `env` context IS available at:
27
+ - Step-level `if:` conditions (steps[*].if)
28
+ - Step `run:` scripts (as environment variables, not expressions)
29
+ - Step `with:` input values
30
+
31
+ `env` context is NOT available at:
32
+ - Job-level `if:` conditions (jobs.<job-id>.if)
33
+ - Workflow-level `env:` values (cannot reference other env vars defined in the same block)
34
+
35
+ A common mistake pattern:
36
+ env:
37
+ DEPLOY_ENV: production
38
+
39
+ jobs:
40
+ deploy:
41
+ if: env.DEPLOY_ENV == 'production' # FAILS — env not available at job level
42
+ runs-on: ubuntu-latest
43
+
44
+ GitHub's expression evaluator may report "Context access might be invalid: env" as
45
+ a workflow validation warning, OR silently evaluate env.DEPLOY_ENV as an empty string
46
+ causing `if:` to evaluate to false — the job is skipped with no error message, only
47
+ a "skipped" status in the Actions UI.
48
+
49
+ The silent skip variant is especially deceptive: the workflow validates without error,
50
+ the job always shows as "skipped", and the developer assumes a logic error rather than
51
+ a context availability limitation.
52
+ fix: |
53
+ At job-level `if:` conditions, use context types that ARE available:
54
+
55
+ 1. vars context (repository/environment/org variables set in GitHub Settings):
56
+ jobs:
57
+ deploy:
58
+ if: vars.DEPLOY_ENV == 'production'
59
+
60
+ 2. inputs context (workflow_dispatch or workflow_call inputs):
61
+ jobs:
62
+ deploy:
63
+ if: inputs.environment == 'production'
64
+
65
+ 3. github context properties (branch, event type, actor, etc.):
66
+ jobs:
67
+ deploy:
68
+ if: github.ref == 'refs/heads/main'
69
+
70
+ 4. needs.<job>.outputs (pass values from a prior job):
71
+ jobs:
72
+ setup:
73
+ outputs:
74
+ target_env: ${{ steps.detect.outputs.env }}
75
+ deploy:
76
+ needs: setup
77
+ if: needs.setup.outputs.target_env == 'production'
78
+
79
+ 5. Move the condition to a step-level if: where env IS available:
80
+ jobs:
81
+ deploy:
82
+ runs-on: ubuntu-latest
83
+ steps:
84
+ - if: env.DEPLOY_ENV == 'production'
85
+ run: ./scripts/deploy.sh
86
+ fix_code:
87
+ - language: yaml
88
+ label: "Use vars context at job-level if: (set variable in GitHub Settings)"
89
+ code: |
90
+ # Set DEPLOY_ENV in GitHub Settings → Secrets and Variables → Variables → Repository variables
91
+ jobs:
92
+ deploy:
93
+ # vars context IS available at job-level if:
94
+ if: vars.DEPLOY_ENV == 'production'
95
+ runs-on: ubuntu-latest
96
+ steps:
97
+ - uses: actions/checkout@v4
98
+ - run: ./scripts/deploy.sh
99
+ - language: yaml
100
+ label: "Move env condition to step-level if: where env context is available"
101
+ code: |
102
+ env:
103
+ DEPLOY_ENV: production
104
+
105
+ jobs:
106
+ deploy:
107
+ runs-on: ubuntu-latest
108
+ # No job-level if: — condition is evaluated at the step level instead
109
+ steps:
110
+ - uses: actions/checkout@v4
111
+ - name: Deploy to production only
112
+ # env IS available at step-level if:
113
+ if: env.DEPLOY_ENV == 'production'
114
+ run: ./scripts/deploy.sh
115
+ - language: yaml
116
+ label: "Use workflow_dispatch input and inputs context at job level"
117
+ code: |
118
+ on:
119
+ workflow_dispatch:
120
+ inputs:
121
+ environment:
122
+ type: choice
123
+ options: [staging, production]
124
+ required: true
125
+
126
+ jobs:
127
+ deploy:
128
+ # inputs context IS available at job-level if:
129
+ if: inputs.environment == 'production'
130
+ runs-on: ubuntu-latest
131
+ steps:
132
+ - run: ./scripts/deploy.sh
133
+ prevention:
134
+ - "Use vars, inputs, github, or needs.<job>.outputs contexts in job-level if: conditions — never env"
135
+ - "Reserve env context for step-level if: conditions and run: scripts where it is available"
136
+ - "Run actionlint — it warns about invalid context usage at each expression location, including env at job level"
137
+ - "GitHub workflow validation may only warn (not error) on invalid context access — always test conditions with a real workflow run before relying on them"
138
+ - "Consult the GitHub Docs context availability table to verify which contexts are valid at each expression location"
139
+ docs:
140
+ - url: "https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#context-availability"
141
+ label: "GitHub Docs — Context availability by expression location"
142
+ - url: "https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables"
143
+ label: "GitHub Docs — Storing information in variables (vars context)"
144
+ - url: "https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution"
145
+ label: "GitHub Docs — Using conditions to control job execution"
146
+ - url: "https://github.com/orgs/community/discussions/29068"
147
+ label: "GitHub Community — env context not available in job-level if conditions"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htekdev/actions-debugger",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "65+ real GitHub Actions errors, queryable by agents. CLI + MCP server + Copilot skills + error database.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",