aliyun / aliyun-log-cli

Command Line Interface for Aliyun Log Service
http://aliyun-log-cli.readthedocs.io
MIT License
60 stars 20 forks source link

Got a unrelated error when create index with index file #54

Open liketic opened 5 years ago

liketic commented 5 years ago

How reproduce: Create index with the following command:

aliyunlog log create_index --project_name=abc  --logstore_name=abc --index_detail="file:///xxxx/xxx/xxx.json"

While xxx.json is the index config file. However, got error

Traceback (most recent call last):
  File "/Users/kel/Gitlab/env/bin/aliyunlog", line 13, in <module>
    sys.exit(main())
  File "/Users/kel/Gitlab/env/lib/python2.7/site-packages/aliyunlogcli/cli_core.py", line 247, in main
    ret = getattr(client, method_name)(**args)
  File "/Users/kel/Gitlab/env/lib/python2.7/site-packages/aliyun/log/logclient.py", line 1387, in create_index
    body = six.b(json.dumps(index_detail.to_json()))
AttributeError: 'str' object has no attribute 'to_json'

After made some investigations, I found the root cause is the config file missed a required field "token", and a error log be printed to log file:

fail to load input via method from_json, try to call constructor for cls: <class 'aliyun.log.index_config.IndexConfig'>
    ex:'token'

The error message is hard to understand. I think the original error message maybe better.