Skip to content

Commit e8b5683

Browse files
committed
fix(lint): a flow node config-value finding carries the slot's key path
validateStackExpressions located a finding on a top-level flow node's config value by its where prose alone, so a draft's _diagnostics path was prose and Studio's Problems row could not select the node. Each node arm now records the key it judged, and the node's findings carry flows[F].nodes[N].<block>.<path>, the edge shape. Nested-region nodes and map-form flows keep where alone, as edges do. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxhpYpVUxgK5jbQMXT
1 parent 34287ec commit e8b5683

3 files changed

Lines changed: 47 additions & 6 deletions

File tree

‎packages/lint/src/authoring-rules.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,8 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
793793
rule: EXPRESSION_INVALID,
794794
where: i.where,
795795
// [#26858] The slot's key path where the pass spells one (a flow edge's
796-
// `condition`), so a draft's `_diagnostics` can address the field.
796+
// `condition`, #27828 a flow node's config value), so a draft's
797+
// `_diagnostics` can address the field.
797798
path: i.path ?? i.where,
798799
// [#22161] The authored source is a QUOTE of what the author wrote, not
799800
// a fix, so it rides the verdict — `— source: \`…\`` is the spelling

‎packages/lint/src/validate-expressions.node-config-path.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,19 @@ describe('a flow node config-value finding carries a key path (#27828)', () => {
8080
// A value slot's retired single-brace token (the template-refusal arm).
8181
{ id: 'tok', type: 'update_record', label: 'Tok', config: { objectName: 'task', filter: { id: 'x' }, fields: { title: '{record.name}' } } },
8282
// A text slot's single-brace token (the text-slot arm).
83-
{ id: 'say', type: 'notify', label: 'Say', config: { channel: 'email', recipients: ['a@b.c'], title: 'Hi {record.name}', message: 'ok' } },
83+
{ id: 'say', type: 'notify', label: 'Say', config: { recipients: ['a@b.c'], title: 'Hi {record.name}', message: 'ok' } },
8484
// A key the node's contract does not declare (the config-refusal arm).
85-
{ id: 'odd', type: 'end', label: 'Odd', config: { bogusKey: 1 } },
85+
{ id: 'odd', type: 'notify', label: 'Odd', config: { bogusKey: 1, recipients: ['a@b.c'], title: 'ok', message: 'ok' } },
8686
// A script with no callable (the script arm).
8787
{ id: 'run', type: 'script', label: 'Run', config: {} },
88+
// A sibling-block value slot (#27968): the path names its block.
89+
{
90+
id: 'call',
91+
type: 'connector_action',
92+
label: 'Call',
93+
config: {},
94+
connectorConfig: { connectorId: 'crm', actionId: 'push', input: { customerId: '{record.id}' } },
95+
},
8896
];
8997
const issues = validateStackExpressions({ flows: [flow(nodes, { edges: [] })] });
9098
const pathsOf = (id: string) => [...new Set(onNode(issues, id).map((i) => i.path))];
@@ -93,6 +101,7 @@ describe('a flow node config-value finding carries a key path (#27828)', () => {
93101
expect(pathsOf('say')).toEqual(['flows[0].nodes[2].config.title']);
94102
expect(pathsOf('odd')).toEqual(['flows[0].nodes[3].config.bogusKey']);
95103
expect(pathsOf('run')).toEqual(['flows[0].nodes[4].config.function']);
104+
expect(pathsOf('call')).toEqual(['flows[0].nodes[5].connectorConfig.input.customerId']);
96105
});
97106

98107
it('a map-form flows collection has no index to spell, so the finding keeps where alone', () => {

‎packages/lint/src/validate-expressions.ts‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ export interface ExprIssue {
165165
* [#26858] The judged slot's key path in the stack, in the spelling the other
166166
* rules' findings carry (`flows[0].edges[1].condition`), beside the human
167167
* `where`. Set only where the slot has one: a top-level flow edge's
168-
* `condition`, and (#27643) an object validation rule's `condition` / `when`
168+
* `condition`, (#27828) a top-level flow node's judged config value
169+
* (`flows[0].nodes[1].config.fields.status`, a sibling block's
170+
* `flows[0].nodes[2].connectorConfig.input.customerId`), and (#27643) an
171+
* object validation rule's `condition` / `when`
169172
* (`objects[0].validations[1].condition`), a nested branch's included
170173
* (`objects[0].validations[1].then.condition`). Absent, the finding is
171174
* located by `where` alone.
@@ -2722,7 +2725,13 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
27222725
// that guarantee stops, through the file's one home for it.
27232726
for (const node of recordsOf(graph.nodes)) {
27242727
const cfg = (node.config ?? {}) as AnyRec;
2728+
// [#27828] Each site below names the key it judged beside its `where`;
2729+
// after the walk, this node's findings carry that key path (see the
2730+
// stamp at the end of this body).
2731+
const nodeFirst = issues.length;
2732+
const nodeSlotKeys = new Map<string, string>();
27252733
const nodeCondWhere = `${at} · node '${node.id}' (${node.type}) condition`;
2734+
nodeSlotKeys.set(nodeCondWhere, 'config.condition');
27262735
if (!checkStructuralCondition(nodeCondWhere, cfg.condition).refused) {
27272736
const from = issues.length;
27282737
check(nodeCondWhere, cfg.condition, objectName);
@@ -2762,8 +2771,10 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
27622771
|| (configRefusal.code === 'node-config-refused-by-contract' && configRefusal.path === 'functionName')
27632772
)));
27642773
for (const configRefusal of configRefusals) {
2774+
const configWhere = `${at} · node '${node.id}' (${nodeType}) config.${configRefusal.path}`;
2775+
nodeSlotKeys.set(configWhere, `config.${configRefusal.path}`);
27652776
issues.push({
2766-
where: `${at} · node '${node.id}' (${nodeType}) config.${configRefusal.path}`,
2777+
where: configWhere,
27672778
message: configRefusal.message,
27682779
source: configRefusal.source,
27692780
severity: 'error',
@@ -2774,6 +2785,7 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
27742785
// `connectorConfig.input` — and names the block it is in.
27752786
for (const found of resolveFlowNodeExpressions(nodeType, cfg, node)) {
27762787
const slotWhere = `${at} · node '${node.id}' (${nodeType}) ${found.entry.label} at ${found.block}.${found.path}`;
2788+
nodeSlotKeys.set(slotWhere, `${found.block}.${found.path}`);
27772789
// [#15137] `value` slots are checkable too, by their own rule — see
27782790
// `checkDeclaredValue`. Not shadowing-checked: the shadow diagnostic is
27792791
// about a bare identifier resolving to a variable instead of a field,
@@ -2832,8 +2844,10 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
28322844
// and the two legacy `assignment` shapes, so build and registration
28332845
// give one verdict, and each refusal names the token's CEL spelling.
28342846
for (const templateRefusal of flowNodeValueTemplateRefusals(nodeType, cfg, node)) {
2847+
const templateWhere = `${at} · node '${node.id}' (${nodeType}) ${templateRefusal.label} at ${templateRefusal.block}.${templateRefusal.path}`;
2848+
nodeSlotKeys.set(templateWhere, `${templateRefusal.block}.${templateRefusal.path}`);
28352849
issues.push({
2836-
where: `${at} · node '${node.id}' (${nodeType}) ${templateRefusal.label} at ${templateRefusal.block}.${templateRefusal.path}`,
2850+
where: templateWhere,
28372851
message: templateRefusal.message,
28382852
source: templateRefusal.source,
28392853
severity: 'error',
@@ -2850,6 +2864,7 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
28502864
// throw at the node mid-run.
28512865
for (const slot of flowNodeTextSlotSources(nodeType, cfg)) {
28522866
const slotWhere = `${at} · node '${node.id}' (${nodeType}) ${slot.label} at config.${slot.path}`;
2867+
nodeSlotKeys.set(slotWhere, `config.${slot.path}`);
28532868
const tokenRefusal = textSlotTemplateRefusal(slot.source);
28542869
if (tokenRefusal !== undefined) {
28552870
issues.push({ where: slotWhere, message: tokenRefusal, source: slot.source, severity: 'error' });
@@ -2879,6 +2894,8 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
28792894
const action = typeof cfg.actionType === 'string' ? cfg.actionType.trim() : '';
28802895
const retired = ['actionType', 'template', 'recipients', 'variables', 'script']
28812896
.filter((k) => cfg[k] != null);
2897+
// The first retired key the author wrote, or the `function` to write.
2898+
nodeSlotKeys.set(`${at} · node '${node.id}' (script) callable`, `config.${retired[0] ?? 'function'}`);
28822899
if (retired.length > 0) {
28832900
issues.push({
28842901
where: `${at} · node '${node.id}' (script) callable`,
@@ -2914,6 +2931,20 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression
29142931
});
29152932
}
29162933
}
2934+
// [#27828] A top-level node's findings also carry the judged slot's key
2935+
// path, the #26858 edge shape (`flows[0].nodes[1].config.fields.status`),
2936+
// indexed over the list the author wrote (the coerced one drops `null`
2937+
// members and would renumber). A nested region's node keeps `where`, as
2938+
// its edges do.
2939+
const nodeIndex = flowIndex >= 0 && graph.path.length === 0 && Array.isArray(flow.nodes)
2940+
? flow.nodes.indexOf(node)
2941+
: -1;
2942+
if (nodeIndex >= 0) {
2943+
for (let k = nodeFirst; k < issues.length; k++) {
2944+
const key = nodeSlotKeys.get(issues[k]!.where);
2945+
if (key !== undefined) issues[k] = { ...issues[k]!, path: `flows[${flowIndex}].nodes[${nodeIndex}].${key}` };
2946+
}
2947+
}
29172948
}
29182949
// `recordsOf`, not `as unknown as AnyRec[]` (#16910) — the same reason as
29192950
// the `graph.nodes` reader above: a NESTED region's edge list is only

0 commit comments

Comments
 (0)