only functions can be called, got null - related to std.prune?
Duologic opened this issue · comments
I ran into this error and can't make sense of it yet. It seems to fail on std.prune
but I can't find a way to reproduce this in smaller snippet.
Here's the stack trace:
only functions can be called, got null
<std>:296:30-35: field <groups> access
<std>:291:20-22: variable <a> access
argument <v> evaluation
<std>:291:8-23: function <builtin_is_array> call
<std>:291:8-291:9: if condition
<std>:296:20-36: function <prune> call
<std>:283:10-12: variable <b> access
<std>:283:13-283:14: if condition
<std>:296:10-37: function <isContent> call
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:79:15-43: function <prune> call
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:79:12-69: if condition
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:79:12-69: evaluating field name
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:98:38-50: field <files> access
<std>:260:24-26: variable <o> access
argument <obj> evaluation
<std>:260:5-34: function <builtin_object_fields_ex> call
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:98:21-51: function <objectFields> call
argument <arr> evaluation
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:95:9-95:10: function <builtin_sort> call
argument <arr> evaluation
vendor/github.com/grafana/jsonnet-libs/prometheus/mixins.libsonnet:95:10-95:11: function <builtin_reverse> call
vendor/github.com/grafana/jsonnet-libs/ksonnet-util/util.libsonnet:231:10-37: function <builtin_manifest_yaml_doc> call
vendor/github.com/grafana/jsonnet-libs/prometheus/ha-mixin.libsonnet:56:19-75: function <manifestYaml> call
field <prometheus-0.yml> manifestification
field <data> manifestification
field <prometheus_config_maps> manifestification
field <main_prometheus> manifestification
field <default> manifestification
Does it fail in some public library? It works for me on the prometheus-operator/kube_prometheus repo, which this output looks like.
It's in https://github.com/grafana/jsonnet-libs/blob/master/prometheus/ but the code I'm calling goes through a few more layers. I'll try to come up with something reproducible when I find the time.
Anyway, the issue here is code like this is run:
local v = null;
v(1)
std.prune
should not cause this, as it is implemented in the same way as cpp-jsonnet one: https://github.com/netomi/jsonnet/blob/96aa98e305a108da5d38f06bb3894324ef50cec4/stdlib/std.jsonnet#L1603
For easier debugging, jrsonnet supports --trace-format option: jrsonnet file.jsonnet --trace-format=explaining