Repository navigation
remove params from anyInputs - #1199
Conversation
WalkthroughThe data readiness check in ComputedNode.checkDataAvailability was modified to exclude the params field from inputs. The method now defaults inputs to {} if undefined, filters out params, calls graph.resultsOf on the cleaned inputs, flattens the results, and checks for any non-undefined value to determine readiness. Changes
Sequence Diagram(s)sequenceDiagram
participant CN as ComputedNode
participant G as Graph
CN->>CN: inputs || {}
CN->>CN: cleanInput = omit(inputs, 'params')
CN->>G: resultsOf(cleanInput)
G-->>CN: results[]
CN->>CN: readiness = flatten(results).some(r !== undefined)
CN-->>CN: return readiness
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/graphai/src/node.ts (2)
241-241: Nit: prefer underscore-prefixed alias for unused binding to appease linters.Some ESLint/TS configs ignore unused variables when they start with an underscore. Using _params (or similar) is less likely to trip no-unused-vars.
-const { params: __, ...cleanInput } = this.inputs ?? {}; +const { params: _params, ...cleanInput } = this.inputs ?? {};
241-245: Add unit tests for anyInput + params exclusion.Recommend adding coverage to lock this behavior:
- anyInput=true, inputs contain both params and a non-params source: becomes ready when non-params value arrives; params alone does not.
- anyInput=true, inputs only under params: does not become ready (or, if you adopt the optional refactor, is not blocked by params-only pendings).
I can draft targeted tests that set up minimal graphs to assert these cases. Want me to open a follow-up PR with tests?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these settings in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/graphai/src/node.ts(1 hunks)
🔇 Additional comments (2)
packages/graphai/src/node.ts (2)
241-245: Change aligns with PR objective: params excluded from anyInput readiness.This correctly ignores the params field when deciding readiness for anyInput nodes. Defaulting to {} prevents destructuring on undefined. The flatten + non-undefined check keeps previous semantics for determining availability.
242-245: Confirm whether null should count as “available.”Currently, readiness treats null as available (only filters out undefined). If the intended semantics are “must be non-nullish,” consider using result != null. If null is a valid, intentional value, the current check is correct.
If null should not trigger readiness:
- .some((result) => result !== undefined); + .some((result) => result != null);
| const { params: __, ...cleanInput } = this.inputs ?? {}; | ||
| return Object.values(this.graph.resultsOf(cleanInput)) | ||
| .flat() | ||
| .some((result) => result !== undefined); | ||
| } |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Risk: anyInput nodes that only have inputs under params may never become ready.
When anyInput is true, removePending clears all pendings only if checkDataAvailability() returns true. Since params are now excluded from that check, a node whose inputs are all under params will never satisfy checkDataAvailability(), yet its pendings still include the params-derived sources (built from inputs2dataSources(data.inputs)). That combination can leave the node stuck.
Consider also excluding params from pendings construction for anyInput nodes so that “params-only” inputs don’t block scheduling:
- Option A (recommended): Build dataSources/pending sources from inputs with params removed when anyInput is true.
For example (outside the changed lines, in the constructor where dataSources are built):
// After: this.inputs = data.inputs;
const { params: _p, ...inputsExcludingParams } = (data.inputs ?? {}) as Record<string, unknown>;
const inputsForSources = this.anyInput ? inputsExcludingParams : (data.inputs ?? {});
this.dataSources = [
...(Object.keys(inputsForSources).length ? inputs2dataSources(inputsForSources).flat(10) : []),
...(this.agentId ? [parseNodeName(this.agentId)] : []),
...(data.passThrough ? inputs2dataSources(data.passThrough).flat(10) : []),
];To help assess whether this would affect existing graphs, you can scan for anyInput nodes whose inputs appear to be params-only:
🏁 Script executed:
#!/usr/bin/env bash
# Heuristic search for anyInput nodes that might rely only on `params`
# This is approximate; please manually review matches.
rg -n --no-heading -C 8 'anyInput\s*:\s*true' \
| rg -n -C 8 'inputs\s*:\s*\{[^}]*params' \
| sed -n '1,200p'Length of output: 105
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "=== Show packages/graphai/src/node.ts (first 400 lines) ==="
sed -n '1,400p' packages/graphai/src/node.ts || true
echo
echo "=== Search for occurrences of anyInput ==="
rg --line-number --hidden --no-ignore 'anyInput' || true
echo
echo "=== Search for inputs2dataSources, dataSources, pendings, removePending, checkDataAvailability, resultsOf ==="
rg --line-number --hidden --no-ignore 'inputs2dataSources|dataSources|pendings|removePending|checkDataAvailability|resultsOf' || true
echo
echo "=== Grep for constructor in node.ts to show how dataSources/pendings are built ==="
rg --line-number "constructor" packages/graphai/src/node.ts -n -S || true
sed -n '1,240p' packages/graphai/src/node.ts || true
# show remainder if file longer
sed -n '241,520p' packages/graphai/src/node.ts || trueLength of output: 260039
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "=== packages/graphai/src/validators/relation_validator.ts ==="
sed -n '1,240p' packages/graphai/src/validators/relation_validator.ts || trueLength of output: 4171
Fix anyInput readiness check: checkDataAvailability ignores params and doesn't use anyInput flag
Short summary:
- I inspected packages/graphai/src/node.ts and packages/graphai/src/validators/relation_validator.ts.
- data.params is not currently added to dataSources/pending (the params line in the constructor is commented out), so the original “params-derived pendings” risk is unlikely with the current constructor.
- However, checkDataAvailability strips a params key from this.inputs but calls this.graph.resultsOf(cleanInput) WITHOUT passing the anyInput flag. For anyInput nodes this mismatch can prevent removePending from clearing pendings when it should.
Places to review:
- packages/graphai/src/node.ts
- constructor: dataSources build (params line is commented out)
- checkDataAvailability() (current lines ~240-245)
- removePending() (current lines ~255-263)
- packages/graphai/src/validators/relation_validator.ts (there is a commented-out params block for validation)
Recommended fix (minimal, recommended)
- Make checkDataAvailability honor the anyInput semantics by passing this.anyInput into resultsOf:
Replace current checkDataAvailability with:
private checkDataAvailability() {
const { params: __, ...cleanInput } = this.inputs ?? {};
return Object.values(this.graph.resultsOf(cleanInput, this.anyInput))
.flat()
.some((result) => result !== undefined);
}Optional defensive change (only if you want to be explicit about params not blocking anyInput nodes)
- If you prefer to ensure pendings never include params-derived sources for anyInput nodes, adjust dataSources construction in the constructor to build sources from inputs with params removed when this.anyInput is true (as in the original suggestion). This is optional because the current constructor already does not include data.params in dataSources.
Reasoning / verification
- I confirmed constructor currently omits data.params from dataSources (it's commented out), so pendings are built from inputs/passThrough/agent only.
- The actionable bug is the missing anyInput flag in checkDataAvailability which causes removePending(this.nodeId) to clear pendings only when resultsOf(cleanInput) (with default anyInput=false) reports data — this can incorrectly keep anyInput nodes waiting.
Tag:
🤖 Prompt for AI Agents
In packages/graphai/src/node.ts around lines 241 to 245, checkDataAvailability
strips params from this.inputs but calls this.graph.resultsOf(cleanInput)
without honoring the node's anyInput flag; update the call to pass this.anyInput
into resultsOf (i.e., this.graph.resultsOf(cleanInput, this.anyInput)) so
anyInput nodes are checked correctly and removePending can clear pendings as
intended.
Exclude params from anyInputs judgment
Summary by CodeRabbit