Skip to content

fix(research): an empty or comment-only workflow file no longer crashes diffci plan - #171

Merged
adityankale190895 merged 2 commits into
DiffCI:mainfrom
FredApps:fix/workflow-parser-empty-file
Nov 18, 2026
Merged

adityankale190895 merged 2 commits into
DiffCI:mainfrom
FredApps:fix/workflow-parser-empty-file

Conversation

@FredApps

Copy link
Copy Markdown
Contributor

Fixes #168

What changed

parseWorkflow (src/research/baseline/workflow-parser.ts) only guarded against a YAML syntax error. YAML.parse returns null for an empty or comment-only file, and the next line read .name from it. analyzeCheckout parses every workflow, so one empty .github/workflows/*.yml made diffci plan fail for the whole repository:

{"error":"Cannot read properties of null (reading 'name')","recommendation":"RUN_FULL_CI"}

A document that isn't a mapping (null, a scalar or a list) has no jobs, so it now returns an empty task list, the same way the existing malformed-file case does. No other behavior changes.

Regression tests

  • tests/research/baseline/workflow-parser.test.ts covers empty, comment-only, scalar and list workflow files. Before the fix, the empty and comment-only cases throw.
  • tests/analyze.test.ts adds "an empty workflow file does not stop the analysis (diffci plan crashes when a workflow file is empty or only comments #168)". Before the fix analyzeCheckout rejects. After it, the plan selects the dependent test.

Validation

…es diffci plan

YAML.parse returns null for such a file, and parseWorkflow read .name
from it, so analyzeCheckout threw for the whole repository.

Fixes DiffCI#168

Signed-off-by: FredApps <[email protected]>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-review at 45abb7c.

Checked:

  • The non-mapping guard returns an empty task list for empty, comment-only, scalar and list documents, which matches the existing malformed-YAML path.
  • The three new tests (two parser cases and the analyzeCheckout case) fail without the guard and pass with it.
  • Typecheck passes, the branch is up to date with main, and CI is green.

Fixed: nothing needed.

Open: nothing.

…test so it merges cleanly with DiffCI#182

No change to the tests themselves. DiffCI#182 appends its path-filter tests at the end of the same describe block.

Signed-off-by: FredApps <[email protected]>
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 01:15
@adityankale190895
adityankale190895 merged commit 26ad96c into DiffCI:main Nov 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diffci plan crashes when a workflow file is empty or only comments

2 participants