opencode icon indicating copy to clipboard operation
opencode copied to clipboard

LayerNode graph should fail with a named error when a dependency is undefined

Open joe-ieta opened this issue 2 months ago • 1 comments

Description

When a layer node's deps array (or a LayerNode.group item) contains undefined, the layer graph walker crashes with:

TypeError: undefined is not an object (evaluating 'node.name')

The stack points into Effect internals rather than the broken node, which makes this hard to diagnose. I hit it in a compiled build where a module export was undefined because of a runtime import cycle; finding the offending node required temporarily patching the walker.

Request

Validate dependencies in LayerNode.make and LayerNode.group and fail with an error that names the owner node and the dependency index, for example:

LayerNode @opencode/v2/FileSystem: invalid dependency at index 2 (undefined)

This is a diagnosability guard; the existing behavior for valid graphs is unchanged.

joe-ieta avatar Sep 18 '26 06:09 joe-ieta

Thanks for the clear write-up, @joe-ieta! You're asking for LayerNode.make and LayerNode.group to check their dependencies when the graph is built. An undefined entry (for example from an import cycle) would then fail with an error naming the owner node and the dependency index, such as LayerNode @opencode/v2/FileSystem: invalid dependency at index 2 (undefined), instead of the opaque TypeError ... 'node.name' from inside Effect.

The graph walker already gives named errors for cycles, unbound nodes and conflicting wiring, so this check would fit with those. I've marked this as a feature request so the maintainers can consider it.

opencodejr[bot] avatar Oct 28 '26 11:10 opencodejr[bot]