Skip to content

Yaml stream separator in a string breaks parsing manifests #341

@eddking

Description

@eddking

Describe the bug
One of the resources in our kubernetes manifests has a yaml document separator string within it's content:

...
---
apiVersion: v1
data:
  install_info: |
    ---
    install_method:
      tool: helm
      tool_version: Helm
      installer_version: datadog-3.135.4
kind: ConfigMap
metadata:
  annotations:
    checksum/install_info: 22bff6a15fb7a4521a3b6a06f55f1fe8ca1570dab4d8bca9f437f28e5301e89a
  labels:
    app.kubernetes.io/instance: datadog
---
...

see install_info is a preformatted string, and contains an indented ---
This should be interpreted as part of the string, not as the start of a new document.

It results in the following error:

Error: kubernetes_manifests: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{"install_method":{"installer_version":"datadog-3.135.4","tool":"helm","tool_version":"Helm"}}' (SQLSTATE HV000)

and no other resources are queryable.

Steampipe version (steampipe -v)
Example: v2.3.2

Plugin version (steampipe plugin list)
Example: v1.5.1

To reproduce
try querying with the above yaml manifest

Expected behavior
I expect any valid kubernetes manifest to be parsed

Additional Context
This is the line where the bug occurs:

for _, resource := range strings.Split(string(content), "---") {

I'd recommend using a yaml parser that supports streams, but if thats not an option, then you could split on only document markers that appear at the start of a line.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsteampipeSteampipe plugin issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions