Skip to content

fix(generator): validate watched_workflows and branches as string lists - #1076

Merged
max-sixty merged 2 commits into
mainfrom
fix/validate-workflow-list-fields
Aug 28, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/validate-workflow-list-fields

Conversation

@tend-agent

@tend-agent tend-agent commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

workflows.<name>.watched_workflows and workflows.<name>.branches were the only list-typed config fields with no type validation — every other one (protected_branches, sandbox_path, sandbox_setup, secrets.allowed) checks isinstance(..., list) and rejects non-string elements. Both render straight into the generated workflow_run: trigger through tojson, so an unchecked value reached the adopter's workflow file verbatim. This adds the same check both fields were missing, plus regression tests.

Four concrete failures, all reproduced before the fix:

Config Before After
watched_workflows: ci renders workflows: "ci" — matches no workflow, so ci-fix silently never fires ClickException at init
watched_workflows: 5 TypeError: object of type 'int' has no len() — a bare traceback out of tend init ClickException at init
watched_workflows: {a: b} a mapping has a length, so it clears the existing empty-list check and renders as a JSON object ClickException at init
branches: [] vacuously a list of non-empty strings, so it renders as branches: [] — a trigger that matches no branch ClickException at init

The scalar case is the one that matters most: it is the natural typo, it passes actionlint, and the only symptom is that tend-ci-fix never runs. Per CLAUDE.md, a config problem should "fail with a clear error, not silently parse".

Verification

The scalar render, reproduced against main before the change:

$ cat .config/tend.yaml
bot_name: test-bot
workflows:
  ci-fix:
    watched_workflows: ci
    branches: main

$ tend init   # rendered .github/workflows/tend-ci-fix.yaml
on:
  workflow_run:
    workflows: "ci"
    types: [completed]
    branches: "main"

actionlint 1.7.12 (the rev pinned in .pre-commit-config.yaml) accepts that file with exit 0, so nothing downstream catches it.

The eight new parametrized cases: 7 fail on main, all 8 pass with the fix. test_branches_explicit_value is the positive control — it passes both ways, confirming a valid list still reaches the trigger. Full suite: 731 passed. ruff format --diff and ruff check clean.

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

One gap left in the same class of failure this PR closes: branches: [] is a list of non-empty strings (vacuously), so the new check accepts it, and it renders straight through as branches: [] in the workflow_run: trigger — which matches no branch, so ci-fix never fires. That is the same silent-never-fires symptom the PR calls out as the one that matters most, and the check three lines below already rejects the symmetric watched_workflows: [] for exactly this reason.

Reproduced on this branch — watched_workflows: ["ci"] plus branches: [] loads without error and renders:

on:
  workflow_run:
    workflows: ["ci"]
    types: [completed]
    branches: []

Suggestion inline. Everything else checks out: the new validation matches the shape the other list fields use, the ordering leaves the existing watched_workflows: [] check reachable (an empty list clears the new all(...)), and hoisting branches out of the WorkflowConfig(...) call is behavior-preserving. Full suite is green here (731 passed), as is CI on this head.

Comment thread generator/src/tend/config.py Resolved
An empty branches list passes the new list-of-non-empty-strings check
vacuously and renders as `branches: []` in the workflow_run trigger,
which matches no branch — the same silent-never-fires symptom as the
scalar case, and what the neighbouring watched_workflows: [] guard
already rejects.
@max-sixty
max-sixty merged commit f5378aa into main Aug 28, 2026
10 checks passed
@max-sixty
max-sixty deleted the fix/validate-workflow-list-fields branch August 28, 2026 15:30
@tend-agent tend-agent mentioned this pull request Aug 30, 2026
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Aug 30, 2026
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.20 → 0.1.22

## Notable changes

- **Notifications now run off a recovery queue** (max-sixty/tend#1074).
The pre-check drops the old layered inbox sweep (shadowed-run and
closed-bot-PR marking) in favour of a single paginated snapshot taken
before a 10-minute cutoff, passes that cutoff through to the agent, and
keeps repository watching enabled with an idempotent `PUT
.../subscription` on every cycle. The job also gains a serial
`tend-notifications` concurrency group.
- **`tend-review` re-targets instead of skipping**
(max-sixty/tend#1082). The "skip when the live HEAD is already examined"
gate step and its `if:` guards are gone; a live session now re-targets
when HEAD moves. The concurrency group adds `queue: max` so a push can't
evict a pending `ready_for_review` run.
- **Skills check the default branch for a landed fix before opening a
PR** (max-sixty/tend#1070), and `review-runs` gains the run census as a
second stranded-trigger drain input (max-sixty/tend#1073).
- **Poll/rerun script fixes** (max-sixty/tend#1053,
max-sixty/tend#1055): `tend-review` no longer gates the CI poll, and an
unresolvable commit fails fast rather than passing silently.
- **Generator fixes**: `watched_workflows` and `branches` are validated
as string lists (max-sixty/tend#1076), and block prompts no longer get
padded blank lines (max-sixty/tend#1090).

Full upstream diff:
max-sixty/tend@0.1.20...0.1.22

Co-authored-by: worktrunk-bot <[email protected]>
max-sixty pushed a commit to max-sixty/leaf that referenced this pull request Aug 30, 2026
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.20 → 0.1.22

**Notable changes**

- Notifications recover work missed while the unread queue was stale,
and the job now runs under its own `tend-notifications` concurrency
group so overlapping schedules serialize instead of racing
(max-sixty/tend#1074).
- Skills check the default branch for a landed fix before opening a PR,
cutting duplicate PRs for work that already merged
(max-sixty/tend#1070).
- `review-runs` gains the run census as a second stranded-trigger drain
input (max-sixty/tend#1073), and reviews re-target when HEAD moves
rather than being discarded (max-sixty/tend#1082).
- The CI poll no longer lets `tend-review` gate it, and the
commit-resolution script fails fast instead of proceeding on an
unresolved SHA (max-sixty/tend#1053, max-sixty/tend#1055).
- The generator validates `watched_workflows` and `branches` as string
lists, and stops padding blank lines inside block prompts
(max-sixty/tend#1076, max-sixty/tend#1090).

max-sixty/tend@0.1.20...0.1.22


**Beyond the regeneration:** 0.1.22's `tend-review.yaml` sets
`concurrency.queue: max`, which GitHub accepts but the pinned
`actionlint` hook rejects, so this PR also adds a scoped `-ignore` for
that one schema message to `.pre-commit-config.yaml` — otherwise `lint`
is red and the PR can't merge on its own CI. Tracked upstream as
max-sixty/tend#1094.

---------

Co-authored-by: leaf-agent <[email protected]>
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