river: duplicate/conflicting error reporting for non-existing identifier
When someone tries to configure an attribute with a non-existing idenitifier such as in the following example, he's presented with two different error messages, about it not being a valid identifier and not being a valid component.
One of the messages comes from Flow's component references resolving, while the other one from River's VMs when looking up an identifier from the scope.
Error: ./cmd/agent/example-config.river:11:14: component "foo" does not exist
10 | detector = "fsnotify"
11 | is_secret = foo
| ^
12 | }
Error: ./cmd/agent/example-config.river:11:14: identifier "foo" does not exist
10 | detector = "fsnotify"
11 | is_secret = foo
| ^^^
12 | }
I'm not sure what's the best approach here, so I'll try to come back with an actual proposal; maybe having both errors is a valid approach?
Ah, interesting. I think we can probably drop the first error in favor of the second; having both is a little annoying.
Flow really doesn't know when something is a component or a normal identifier that will resolve, so it should probably leave error reporting to the actual evaluator if it can't look up an identifier as a component.
This is an interesting case; I'm not sure which error is the best. When we set is_secret = foo.bar, both errors make sense until we know if we're accessing an object field or a component's exports.
In any case, the component %s does not exist message is the only error being reported when wiring the graph edges. I'm trying to understand if we should just get rid of it and report all failed traversals in a component as not found identifiers.
I'm closing this issue as completed; somewhere along the line we've fixed this issue.
A config like the following will only report a single error
local.file "secret_key" {
filename = "/tmp/hey.txt"
is_secret = foo
}
$ ./build/grafana-agent-flow run 2110.river
Error: 2110.river:3:15: component "foo" does not exist
2 | filename = "/tmp/hey.txt"
3 | is_secret = foo
| ^
4 | }