Skip to content

ci(claude): fix yq expression in auth-gate-invariants validator#453

Merged
heskew merged 1 commit intomainfrom
workflow/fix-yq-validator-expression
May 2, 2026
Merged

ci(claude): fix yq expression in auth-gate-invariants validator#453
heskew merged 1 commit intomainfrom
workflow/fix-yq-validator-expression

Conversation

@heskew
Copy link
Copy Markdown
Member

@heskew heskew commented May 1, 2026

Summary

Every PR has been failing `Auth gate invariants / validate` with:

```
=== Validating .github/workflows/claude-issue-to-pr.yml ===
Error: .github/workflows/claude-issue-to-pr.yml: authorize job has no step setting USERS_TO_CHECK env var ...
Error: Process completed with exit code 1.
```

…even on workflows that clearly set `USERS_TO_CHECK`. Reproduced locally — the validator's check uses jq's `// empty` keyword, but the runner's yq is mikefarah/yq (Go), which doesn't have it. yq's lexer rejects the expression; `2>/dev/null` swallowed the error; the variable came back empty; the existence check tripped on every workflow.

Fix

Rewrite the yq expression in idiomatic mikefarah/yq syntax:

  • before: `yq -r '[.jobs.authorize.steps[].env.USERS_TO_CHECK // empty] | .[0] // ""' "$f" 2>/dev/null`
  • after: `yq -r '.jobs.authorize.steps[].env.USERS_TO_CHECK | select(. != null)' "$f" 2>/dev/null | head -1`

`select(. != null)` skips steps without the env var; `head -1` collapses the per-step stream to a single value (or empty) for the `[ -n ]` check.

Verified locally with mikefarah/yq v4.53.2 against all three harper `claude-*.yml` workflows — all pass.

Out of scope (followups)

Test plan

  • Push to a PR after this lands → confirm `Auth gate invariants / validate` passes.
  • Merge oauth#68 with the same fix mirrored.

🤖 Generated with Claude Code

Symptom: every PR was failing `Auth gate invariants / validate`
with `authorize job has no step setting USERS_TO_CHECK env var`,
even on workflows that clearly set it. Reported on PR #452 and
others.

Cause: the check `USERS_TO_CHECK presence` (added in #417 review-
fixup) was using a jq-flavored expression — `// empty` in
particular — but yq on ubuntu-latest is `mikefarah/yq` (Go), not
jq. yq's lexer rejects `empty`. The script had `2>/dev/null` on
the yq invocation, so the lexer error was eaten and the variable
came back as the empty string, tripping the existence check on
every workflow.

Fix: rewrite the expression in idiomatic yq:
- `.jobs.authorize.steps[].env.USERS_TO_CHECK | select(. != null)`
  — emits a stream of one value per step that sets the env var,
  skipping steps that don't.
- `head -1` collapses the stream to a single value (or empty)
  for the `[ -n ]` check.

Verified locally with mikefarah/yq v4.53.2 against all three
harper claude-*.yml workflows — all pass.

Out of scope but worth following up:
- The `2>/dev/null` swallowed a real yq error. Worth either
  removing the suppression or capturing stderr for diagnostics
  when the expression returns empty.
- oauth's mirror (#68) carries the same bug; a copy of this
  fix needs to land there too.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@heskew heskew requested review from a team as code owners May 1, 2026 23:24
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 1, 2026

Reviewed; no blockers found.

@heskew heskew merged commit c171340 into main May 2, 2026
24 of 25 checks passed
@heskew heskew deleted the workflow/fix-yq-validator-expression branch May 2, 2026 22:33
heskew added a commit to HarperFast/oauth that referenced this pull request May 2, 2026
Mirror of HarperFast/harper#453. Same one-line fix.

The validator's USERS_TO_CHECK presence check used jq's `// empty`
keyword, but ubuntu-latest's yq is mikefarah/yq (Go). yq's lexer
rejects `empty`; `2>/dev/null` ate the error; the variable came
back empty; the existence check tripped on every workflow.

Replaces the expression with idiomatic yq:
`.jobs.authorize.steps[].env.USERS_TO_CHECK | select(. != null)`
piped through `head -1`.

Verified locally with mikefarah/yq v4.53.2 against all three
oauth claude-*.yml workflows — all pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants