bottlerocket-test-system icon indicating copy to clipboard operation
bottlerocket-test-system copied to clipboard

TestSys CLI does not return useful yaml formatting errors

Open jpmcb opened this issue 3 years ago • 3 comments

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.

jpmcb avatar Aug 17 '22 22:08 jpmcb

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.

mjsterckx avatar Aug 19 '22 13:08 mjsterckx

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!

jpmcb avatar Aug 19 '22 13:08 jpmcb

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

webern avatar Oct 24 '22 21:10 webern