Skip to content

fix(agent-client): only fire change hook for fields that declare one#1762

Merged
nbouliol merged 3 commits into
mainfrom
feature/prd-778-executor-ai-form-fill-hookless-change
Jul 16, 2026
Merged

fix(agent-client): only fire change hook for fields that declare one#1762
nbouliol merged 3 commits into
mainfrom
feature/prd-778-executor-ai-form-fill-hookless-change

Conversation

@nbouliol

@nbouliol nbouliol commented Jul 15, 2026

Copy link
Copy Markdown
Member

Problem

Running a smart action through the workflow executor (trigger-record-action, AI-assisted or Full AI) crashes against Ruby (forest_liana) agents: getActionForm failed: Agent responded with HTTP 500, the agent raising NoMethodError: undefined method 'call' for nil:NilClass. Manual form fill in the Ember UI works; Node agents tolerate it.

Root cause

FieldFormStates.setFieldValue posted to /hooks/change for any field as soon as the action declared at least one change hook, without checking the changed field had its own hook. tryToSetFields iterates every AI-filled field, so setting a hookless field (e.g. code) sent changed_field for it; forest_liana then evaluated action.hooks[:change][nil].call and raised. The Ember UI only fires a change for fields that declare a hook.

Fix

  • Gate loadChanges on the changed field's own hook, matching the admin UI.
  • Thread the per-field hook through PlainField, ForestSchemaAction.fields, and the loadInitialState fallback mapping so it is reliably available (Node sets changeHook only on watched fields; Ruby sets the hook name).

Tests

field-form-states suite green (20/20), incl. a new regression test: a hookless field does not trigger a change even when the action has change hooks.

Fixes PRD-778

🤖 Generated with Claude Code

Note

Fix setFieldValue to only fire change hook for fields that declare one

Previously, FieldFormStates.setFieldValue triggered a POST to /hooks/change based on whether hooks.change had entries, regardless of whether the specific changed field declared a hook. Now it checks field.getPlainField().hook and skips the request for fields without a hook.

  • Adds an optional hook?: string property to PlainField in types.ts and ForestSchemaAction fields in forestadmin-client types.ts.
  • Updates loadInitialState to forward the hook property when mapping fallback fields, so hook-based change behavior works correctly for those fields too.
  • Behavioral Change: fields without a declared hook no longer trigger change hook requests even if the action has hooks.change defined.

Macroscope summarized a243be3.

nbouliol and others added 2 commits July 15, 2026 16:49
Action form fields can declare a change hook; expose it on ForestSchemaAction.fields so clients can tell which fields trigger a change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
setFieldValue posted to /hooks/change for any field whenever the action had at least one change hook, without checking the changed field itself declared a hook. Filling a hookless field via the workflow executor thus sent changed_field for it, and forest_liana crashed evaluating hooks[:change][nil].call (NoMethodError, HTTP 500). The Ember UI only fires a change for fields declaring a hook.

Gate loadChanges on the changed field's own hook, and thread the hook attribute through PlainField and the load fallback so it is reliably available.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 15, 2026

Copy link
Copy Markdown

PRD-778

@qltysh

qltysh Bot commented Jul 15, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/agent-client/src/action-fields/field-form-states.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@nbouliol nbouliol merged commit 157a6f8 into main Jul 16, 2026
32 checks passed
@nbouliol nbouliol deleted the feature/prd-778-executor-ai-form-fill-hookless-change branch July 16, 2026 08:54
forest-bot added a commit that referenced this pull request Jul 16, 2026
## @forestadmin/forestadmin-client [1.40.5](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/forestadmin-client@1.40.4...@forestadmin/forestadmin-client@1.40.5) (2026-07-16)

### Bug Fixes

* **agent-client:** only fire change hook for fields that declare one ([#1762](#1762)) ([157a6f8](157a6f8))
forest-bot added a commit that referenced this pull request Jul 16, 2026
## @forestadmin/agent-client [1.10.2](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/agent-client@1.10.1...@forestadmin/agent-client@1.10.2) (2026-07-16)

### Bug Fixes

* **agent-client:** only fire change hook for fields that declare one ([#1762](#1762)) ([157a6f8](157a6f8))

### Dependencies

* **@forestadmin/forestadmin-client:** upgraded to 1.40.5
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