google / google/go-jsonnet

parseYaml inserts null when document stream starts with a comment

Open
#660 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
1.8k
Forks
263
PR merge metrics
No merged PRs in 30d

Description

I just found out that a null value is added to the array when I parse a stream of YAML documents that starts with a comment.

**YAML**

```yaml
# Test
---
foo: bar
---
baz: cuux
```

**Jsonnet**

```jsonnet
std.parseYaml(importstr 'test.yaml')
```

**Result**

```json
[
null,
{
"foo": "bar"
},
{
"baz": "cuux"
}
]
```

**Expected Result**

```json
[
{
"foo": "bar"
},
{
"baz": "cuux"
}
]
```

**Current Workaround**

```jsonnet
std.prune(std.parseYaml(importstr 'test.yaml'))
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.