ERROR: no anchor processing for JSON when using std.parseYaml from python
benjackson-btcs opened this issue · 2 comments
benjackson-btcs commented
When using the python bindings (jsonnet-0.20.0), an abort is hit when using std.parseYaml
with a file containing anchors.
Steps to reproduce: using jsonnet
import, simply std.parseYaml
on any YAML containing anchors.
Minimal example:
(env) jsonnet-python-yaml]$ python3
Python 3.11.4 (main, Jul 13 2023, 11:22:49) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18.0.2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _jsonnet as jsonnet
>>> jsonnet.evaluate_snippet('test.yaml', """
... std.parseYaml(|||
... foo: &foo bar
... bar: *foo
... |||)
... """
... )
ERROR: no anchor processing for JSON
Aborted (core dumped)
I can confirm this same abort when using evaluate_file
too
(env) jsonnet-python-yaml]$ cat test.jsonnet
std.parseYaml(|||
foo: &foo bar
bar: *foo
|||)
(env) [benjamin.jackson@stol-core1 jsonnet-python-yaml]$ python3
Python 3.11.4 (main, Jul 13 2023, 11:22:49) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18.0.2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _jsonnet as jsonnet
>>> jsonnet.evaluate_file('test.jsonnet')
ERROR: no anchor processing for JSON
Aborted (core dumped)
Env:
(env) [ jsonnet-python-yaml]$ pip freeze
jsonnet==0.20.0
(env) [jsonnet-python-yaml]$ uname -a
Linux xx 5.4.17-2011.7.4.el8uek.x86_64 #2 SMP Fri Oct 2 14:39:04 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux
(env) [jsonnet-python-yaml]$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)
benjackson-btcs commented
For the record, the jsonnet
cli does not choke on these same inputs:
(env) [jsonnet-python-yaml]$ jsonnet test.jsonnet
{
"bar": "bar",
"foo": "bar"
}
benjackson-btcs commented
Actually, this exact issue is present with pure libjsonnet:
#include <iostream>
extern "C" {
#include <libjsonnet.h>
}
int main(int argc, char** argv)
{
JsonnetVm *vm = jsonnet_make();
int error{};
char *result = jsonnet_evaluate_snippet(vm, "test.jsonnet", R"(
std.parseYaml(|||
foo: &foo bar
bar: *foo
|||)
)", &error);
if (error)
{
std::cerr << "Error: " << result << std::endl;
}
else
{
std::cout << result << std::endl;
}
jsonnet_realloc(vm, result, 0);
jsonnet_destroy(vm);
}
(env) [jsonnet-go-c]$ LD_LIBRARY_PATH=/home/benjamin.jackson/repos/github/google/jsonnet/build ./a.out
/home/benjamin.jackson/repos/github/google/jsonnet/third_party/rapidyaml/ryml_all.hpp:23120:JSON does not have anchors
Aborted (core dumped)