fix: add expression eval to input macros, fuzz infrastructure, String() fixes#14
Conversation
Input macro commands (input.keyboard, input.gamepad) processed characters one at a time with no expression handling, causing [[expression]] syntax to be split into individual characters instead of being evaluated. Closes #2
…trip bugs
Add FuzzParseTagFilters and FuzzCommandString fuzz targets. The round-trip
fuzzer (parse → String() → reparse) found and fixed several serialization
bugs in Command.String():
- Normalize command name before isInputMacroCmd check (mixed case used wrong parser)
- Quote args containing *, [, #, {, ' in String() output
- Escape [ inside quoted args to prevent expression parsing
- Escape \, ?, [, {, | in input macro String() output
- Quote explicit empty string args as "" to distinguish from no args
- Skip empty arg when colon has no content (argWritten tracking)
Add fuzz task to Taskfile.yml matching zaparoo-core's pattern with
configurable FUZZ_TIME. Add dedicated nightly fuzz.yml workflow with crash
artifact upload and automatic issue creation. Remove inline fuzz from CI
(corpus regressions still run via go test).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughReorganizes fuzz testing into a dedicated scheduled workflow, adds a Taskfile fuzz task and multiple fuzz tests/corpus seeds, implements expression interpolation for input-macro args and refines arg-empty vs missing semantics, normalizes command names, and updates argument serialization/escaping logic. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/fuzz.yml:
- Around line 1-75: The workflow pins an unverified commit for the
arduino/setup-task action (uses:
arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611) instead of the
official v2.0.0 release SHA; update the uses entry for the Task setup step to
reference the verified v2.0.0 commit (SHA
24c5e13bce349197642746563945fcdf9359e8f4) so the step that sets up Task
(Taskfile.yml) is pinned to the correct, audited release.
In `@parser_mutation_test.go`:
- Around line 811-819: Add a paired explicit-empty test row next to the "empty
arg from colon only" case in the parser_mutation_test.go table to ensure
`**cmd:""` and `**cmd:''` parse to an explicit empty arg (Args: []string{""})
rather than being treated as omitted; update the test table that constructs
zapscript.Script with Cmds containing zapscript.Command{Name: "cmd", Args:
[]string{""}} for those inputs so the parser's empty-vs-omitted behavior is
covered.
In `@parser.go`:
- Around line 206-209: The current usage of hasArgs(args) in the auto-launch
parsing path drops explicit empty arguments parsed by parseArgs (which sets
argWritten) and causes inputs like "" or ""?launcher=x to lose the
caller-intended empty target; remove the broad hasArgs(args) check in this
location and instead preserve args when parseArgs indicated an explicit write
(check argWritten or equivalent from parseArgs) so cmd.Args remains the explicit
empty string when provided, and move any hasArgs-based filtering into the
specific "cmd:" fallback caller where that behavior is intended (or
conditionally apply hasArgs only when argWritten is false).
In `@reader.go`:
- Around line 167-186: Command.String() is using the raw c.Name to decide
input-macro serialization, causing mixed-case names like "input.keYBoArd" to be
serialized incorrectly; update the input-macro check in the serialization path
to use the same normalized form as parseCommand (e.g., lowercase or the same
normalization function) before calling isInputMacroCmd so that
parseInputMacroArg and String() branch consistently (refer to isInputMacroCmd,
parseCommand, parseInputMacroArg, and Command.String()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 60a228e2-a69d-4b29-822f-bee91af55c5b
📒 Files selected for processing (21)
.github/workflows/ci.yml.github/workflows/fuzz.ymlTaskfile.ymlarguments.goparser.goparser_coverage_test.goparser_fuzz_test.goparser_mutation_test.goreader.gosymbols.gotestdata/fuzz/FuzzCommandString/01ca04e414360be4testdata/fuzz/FuzzCommandString/085789c0f347eb2dtestdata/fuzz/FuzzCommandString/1db92f3d0ef87c11testdata/fuzz/FuzzCommandString/665c2cce8688359ctestdata/fuzz/FuzzCommandString/718a940357f048d5testdata/fuzz/FuzzCommandString/98522f8ffcdcc781testdata/fuzz/FuzzCommandString/a50862c2ccfa2e7etestdata/fuzz/FuzzCommandString/b79ed5e224f405a6testdata/fuzz/FuzzCommandString/b7a29d913cf174b2testdata/fuzz/FuzzCommandString/c9b801b582d4ff5dtestdata/fuzz/FuzzCommandString/e187a4af421c245b
💤 Files with no reviewable changes (1)
- .github/workflows/ci.yml
- Add paired explicit-empty test cases (**cmd:"" and **cmd:'') next to the empty-colon test to document the argWritten behavior contract - Replace hasArgs with len(args) > 0 in parseAutoLaunchCmd to preserve explicit empty args from quoted input - Normalize command name in String() before isInputMacroCmd check for consistent serialization of programmatically-constructed commands - Remove unused hasArgs function
Summary
[[expression]]evaluation support to input macro commands (input.keyboard,input.gamepad), fixing Input macro commands don't support expression evaluation #2FuzzParseTagFiltersandFuzzCommandStringfuzz targets with round-trip property testingCommand.String()serialization bugs found by fuzzing:isInputMacroCmdcheck (mixed case used wrong parser)*,[,#,{,'characters[inside quoted args to prevent expression parsing\,?,[,{,|in input macro output""to distinguish from no argsargWrittentracking)fuzztask to Taskfile with configurableFUZZ_TIMEfuzz.ymlworkflow with crash artifact upload and auto-issue creationgo test)Closes #2
Summary by CodeRabbit
New Features
Tests
Chores