bottlerocket-os / bottlerocket-test-system

A system for testing Bottlerocket
Other
18 stars 24 forks source link

TestSys CLI does not return useful yaml formatting errors #517

Open jpmcb opened 2 years ago

jpmcb commented 2 years ago

Given a test yaml that looks like:

---
apiVersion: testsys.bottlerocket.aws/v1
kind: Test
metadata:
  name: hello-bones
  namespace: testsys-bottlerocket-aws
spec:
  agent:
    name: hello-agent
    image: "example-test-agent:demo"
    keep_running: false
    configuration:
      mode: Fast
      person: Bones the Cat
      helloCount: 3
      helloDurationMilliseconds: 500
  resources: []
  dependsOn: []

and attempting to run it:

❯ cli run file example_test_agent.yaml
Unable to read manifest

_Note that the keep_running key should be keepRunning_. The CRD key error isn't bubbled up from the underlying read_manifest

https://github.com/bottlerocket-os/bottlerocket-test-system/blob/e4c6d22e76cacde344ef0765ed5630edf15ea58e/cli/src/run_file.rs#L17

Still new to rust, but it would be great if a more descriptive error was returned.

mjsterckx commented 2 years ago

I was looking into this, but the only error message that can really "bubble up" is this: data did not match any variant of untagged enum Crd

There seems to be an open PR for the serde repo (https://github.com/serde-rs/serde/pull/1544) that has not been merged yet, but it would solve this issue as well. The only other solution that I can think of for the moment is to manually parse the YAML file.

jpmcb commented 2 years ago

The only other solution that I can think of for the moment is to manually parse the YAML file.

Nice find! This seems like something the upstream de-serializing library should report errors back on and not something we'd want to do extra work by do an additional yaml parsing. Can keep an eye on that PR!

webern commented 2 years ago

It might be necessary to print anyhow::Error with debug {:?} to see the underlying error "pseudo stack trace"