Skip to content

fix(tree): reject non-string hook matchers - #164

Open
JesstLe wants to merge 2 commits into
google-research:mainfrom
JesstLe:fix/hook-matcher-validation-20261102
Open

JesstLe wants to merge 2 commits into
google-research:mainfrom
JesstLe:fix/hook-matcher-validation-20261102

Conversation

@JesstLe

@JesstLe JesstLe commented Nov 2, 2026 •

Copy link
Copy Markdown

Problem

check_hooks() validates the matcher group and its handlers, but accepts a non-string matcher, such as 42, true, a list, or an object. tree.validate(CODEX_SURFACE, proposed) consequently accepts these proposals and reports one hook file.

The pinned Codex 0.144.6 schema declares MatcherGroup.matcher as Option<String>. Its discovery loader deserializes the entire HooksFile; an incompatible matcher causes it to warn and discard the file, including otherwise valid sibling hooks.

Change

Reject non-null, non-string matchers at the existing proposal-validation boundary, with the file, event, and group index in the error. Preserve missing/null/string matchers and keep accumulating handler errors. Do not coerce or rewrite the proposed JSON.

Regression tests exercise the public tree.validate() entry point: eight invalid values; missing, null, empty, plain, and regex-string controls; and an invalid group among valid siblings.

Related: #142 checks handler command types. This PR checks group matcher types only; it does not include the command or timeout changes.

Verification

python -B -m unittest discover -s tests -p test_hook_matcher_validation.py -v
  • Python 3.12.14 before the fix: Ran 3 tests / FAILED (failures=9).
  • After the fix: Ran 3 tests / OK.
  • Restoring only tree.py in an independent copy restores the same nine failures.
  • Ruff check, Ruff format check, and git diff --check pass.

I also ran the complete suite on the baseline plus the new tests and on the patch. Neither full suite is green in this environment, so this is not a claim of full-suite acceptance:

Environment Baseline + new tests Patched
Windows / Python 3.12 73 tests; 42 failures, 49 errors, 1 skip 73 tests; 33 failures, 49 errors, 1 skip
Offline python:3.12-slim, canonical Git-blob source 73 tests; 24 failures, 12 errors 73 tests; 15 failures, 12 errors

The failing case names are identical after removing the nine fixed matcher failures; no new failing case was introduced. Existing failures include POSIX-only imports on Windows and fixture/provenance checks in the full suite. No Codex/model invocation or benchmark run was used; the downstream loader behavior above was checked against the pinned source.

The reproducer and tests above were executed locally.

@google-cla

google-cla Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@JesstLe

JesstLe commented Nov 2, 2026

Copy link
Copy Markdown
Author

I've signed the Google Individual CLA and confirmed that my GitHub username (JesstLe) is associated with the agreement. However, the "New Contributors" rescan flow returns HTTP 400 after clicking "Rescan", and the cla/google check still reports "Missing CLA".

Could a maintainer please rerun the CLA check or advise on the next troubleshooting step? Thanks!

@JesstLe

JesstLe commented Nov 2, 2026

Copy link
Copy Markdown
Author

Update: the cla/google check now passes — I re-triggered it by pushing an empty commit (556d3b4), so no CLA action is needed anymore.

The remaining Google GitHub Admin: Actions Workflow Security Scan still reports action_required, and its details aren't visible to external contributors. Could a maintainer take a look when reviewing? This PR only touches harness2/core/tree.py and tests/test_hook_matcher_validation.py. Thanks!

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.

1 participant