zalando-zmon / zmon-cli

ZMON Command Line Interface
http://zmon.readthedocs.org/en/latest/developer/zmon-cli.html
Other
9 stars 9 forks source link

Allow .yml file extension or provide a better error message when encountering it. #58

Closed peteraba closed 4 years ago

peteraba commented 7 years ago

Using .yml instead of .yaml is currently not supported, but the error message is very cryptic about wrong extension name.

# zmon e push website.yml                                                                                                                                    
Traceback (most recent call last):
  File "/usr/bin/zmon", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/zmon_cli/main.py", line 9, in main
    cli()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/decorators.py", line 27, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/zmon_cli/cmds/entity.py", line 74, in push_entity
    data = json.loads(entity)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
hjacobs commented 7 years ago

We should probably just try to parse as YAML always (JSON is also valid YAML).

beverage commented 6 years ago

@vetinari Do we want to finish this?