Repository navigation
fix(agent): ignore a Switch condition item with no operand - #22667
Conversation
The front end's "Add" button appends `{operator}` and nothing else, and the
schema accepts an empty cpn_id, so a condition row can be saved without an
operand. normalizeLegacyGroup built a clause for it anyway: left became "", and
comparing "" with the absent value satisfies contains, "=" and empty, so the
group matched and the run was routed to a branch whose condition was never
configured.
The Python implementation skips those items (`if not item["cpn_id"]: continue`),
and this is the second half of infiniflow#15643: evaluateGroup already refuses to match an
empty clause list, with a comment naming the skipped cpn_id items, but nothing
ever skipped them, so that guard never fired.
Skip the item when neither cpn_id nor left names an operand. A sibling clause
that is fully configured still decides the group, which the second test pins.
|
The Could someone add it? Everything else is ready: one commit on current |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes #22666
What was wrong
A Switch condition item with no operand — no
cpn_id, noleft— was not skipped bynormalizeLegacyGroup. The clause was built withleft: "", and comparing""with the item's absentvaluesatisfiescontains,=andempty, so the group matched and the run was routed to that branch instead of falling through toELSE/end_cpn_ids.The web form creates this item on its own: "Add" appends
{operator}only,cpn_idis a plainz.string()with no minimum length, and nothing filters unfilled rows before save.This is the second half of #15643.
evaluateGroupalready refuses to match an empty clause list and its comment names "all skippedcpn_ids", but nothing ever skipped them, so the guard never fired for this shape. The existingTestSwitch_LegacyEmptyItemsFallsThroughcovers the intent yet only passes because its item carriesvalue: "x", which cannot match an empty left.The change
internal/agent/component/switch.go— skip the item whenlegacySwitchLeftyields nothing, matching Python'sif not item["cpn_id"]: continue. An item that names aleftliteral or acpn_idis untouched, so the newerleftform keeps working.Tests
internal/agent/component/switch_test.go:TestSwitch_LegacyIncompleteItemFallsThrough— four shapes of an unfilled row (containswithout value,=with an empty value,empty,not empty) must land on the default target. Three of the four fail without the fix;not emptyis included so the table covers both polarities.TestSwitch_IncompleteItemDoesNotDisableSiblingClauses— one unfilled row plus one configured clause still routes on the configured clause.Full package run:
gofmt,go vetand the repo'stools/hooks/check_files.pychecks (eof, trailing whitespace, mixed line endings, ASCII comments, case conflicts, merge conflicts) are clean.Not covered
The newer
clausesform is unchanged: it is produced by the Go canvas rather than the web form, so an emptyleftthere has no Python counterpart to compare against. I kept the change to the legacyitemspath where parity is defined.