Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

JSON/YAML marshalling fails on empty file - should error with file doesn't exist #54

Open
sygibson opened this issue Aug 22, 2019 · 1 comment

Comments

@sygibson
Copy link
Contributor

When an operator specifies a non-existent JSON/YAML file for parsing, the system produces the above error. This error leads the operator to believe that content may have triggered the marshalling error. Instead, the actual file does not exist.

EXAMPLE:

ls: cannot access foo.yaml: No such file or directory
# drpcli contents create foo.yaml
Error: Error parsing layer: error unmarshaling JSON: json: cannot unmarshal string into Go value of type models.Content

EXPECTED RESULT:
Something more along the lines of an error message like:
cannot access foo.yaml: no such file or directory

@galthaus
Copy link
Contributor

well - sooo - this is one of those you can't have your cake and eat it too without changing your behavior. The problem is that the parameter following the create is one of 4 thing:

  • a filename
  • a JSON string
  • a string

The cli tests it in that order. '-' which tells the the cli to read from standard in. The value is tested as a filename to see if exists. Then the string is parsed a JSON/YAML and then it is passed as just a string. The function that handles this is used everywhere to make it consistent. This means that when you set a parameter with this style it will eventually default to a implied string type. For the object create functions, this means that string is passed as the object to create and it fails in remarshaling.

I'm not sure how to fix this easily without changing someone's operational pattern that might be working. It could be that we do something specific, but I'm not sure.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants