nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] A subscribe entry with a mistyped key is accepted and silently becomes "every file"

Open addyCooks opened this issue 2 weeks ago • 2 comments

Description

subscribe: entries ignore keys they do not know. If someone writes path: instead of paths:, the entry becomes {kind: "file.changed"} with no filter, so the daemon starts a run on every file change in the project.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at 5df35b3a)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. Create a command file:

     ---
     description: d
     subscribe:
       - kind: file.changed
         path: "docs/**"
     ---
     Body
    
  2. Run parseCommandFile(file) and look at result.subscribe.

Expected Behavior

The entry is rejected with a message such as subscribe[0]: unknown key "path" (did you mean "paths"?), and the file loads without triggers, like other invalid blocks.

Actual Behavior

subscribe: [{"kind":"file.changed"}]

No message is shown.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder (main)

Suggested fix:

  • source/skills/parse-subscribe.ts:79 (parseTrigger) and the per-kind functions (parseFileChanged at line 137, and the others): list the allowed keys per kind and throw SubscribeParseError for any other key. The caller already logs it and loads the file without triggers.
  • Check source/skills/manifest-parser.ts for the bundle subscribe: block.
  • Add tests for each kind with an unknown key.

addyCooks avatar Nov 16 '26 09:11 addyCooks

Root cause: parseTrigger in source/skills/parse-subscribe.ts only reads the keys it knows, so a typo such as path: instead of paths: is dropped without a message. The entry then becomes {kind: "file.changed"}, which the event router treats as "every file".

Proposal: add an allowed-keys list per trigger kind (the common fields plus each kind's own) and throw SubscribeParseError on any other key, with a "did you mean" hint when it is close to a known one. The caller already logs that error and loads the file without triggers. I would also check the bundle subscribe: block in manifest-parser.ts, and add one test per kind with an unknown key.

I'd like to take this one. Could you assign it to me or confirm, per CONTRIBUTING, before I open a PR?

This comment was drafted with the help of an AI assistant (Claude).

pcbeingused33 avatar Nov 17 '26 08:11 pcbeingused33

Assigned @pcbeingused333, go ahead.

akramcodez avatar Nov 19 '26 08:11 akramcodez