Skip to content

check-risk-paths: the workflow sync check fails with ENOENT in a repository that vendors the library but has no pr-triage.yml #257

Closed

Description

@frostyard-machines

Problem

scripts/check-risk-paths.mjs runs the workflow sync check when the library exists under --root (existsSync(resolve(root, LIBRARY_PATH)), lines 89 to 99 at 17ea42d). The comment says "The sync check applies where the library lives (core)". But a repository that vendors scripts/lib/risk-paths.mjs (as the risk-paths spec allows, with a sha256 pin) also has that file, and it usually has no .github/workflows/pr-triage.yml. Then checkSync (scripts/sync-risk-paths-workflow.mjs, line 78) reads a missing file, and the gate fails with ENOENT, on a list that is valid.

Repro (core origin/main at 17ea42d)

T=$(mktemp -d); mkdir -p "$T/core" "$T/repo/.github" "$T/repo/scripts/lib"
git archive origin/main scripts | tar -x -C "$T/core"
cp "$T/core/scripts/lib/risk-paths.mjs" "$T/repo/scripts/lib/"
cat > "$T/repo/.github/risk-paths.json" <<'JSON'
{ "schema_version": 2, "default_level": "L3", "paths": [
  { "glob": ".github/risk-paths.json", "level": "L2", "why": "governance: the list" },
  { "glob": ".github/workflows/**", "level": "L2", "why": "governance: the caller" } ] }
JSON
node "$T/core/scripts/check-risk-paths.mjs" --root "$T/repo"

Result:

FAIL risk-paths: ENOENT: no such file or directory, open '/tmp/tmp.…/repo/.github/workflows/pr-triage.yml'
FAIL risk_paths: 1 problem(s)

Exit code 1. Control: the same fixture without scripts/lib/risk-paths.mjs prints ok risk_paths: 2 entries, 2 at L1 or L2 name a category or boundary and exits 0.

Expected

The sync check applies only where the reusable workflow lives. When .github/workflows/pr-triage.yml does not exist under --root, skip the sync check (no failure, no "workflow in sync" in the ok line), as the gate does now when the library is missing.

Acceptance

  • check-risk-paths with a vendored scripts/lib/risk-paths.mjs and no .github/workflows/pr-triage.yml passes on a valid list, and its ok line does not say "workflow in sync".
  • Core itself still fails when the embedded copy drifts (the existing tests check-risk-paths fails when the pr-triage copy drifts and check-risk-paths passes on a fixture whose copies are in sync stay green).
  • 1 new test in test/risk-paths.test.mjs for the vendored case; it fails without the fix.
  • Other read errors (for example a pr-triage.yml that exists but has no embedded block) still fail.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions