Config should be validated with clearer errors

未关闭
#45 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

从 mautrix/util/config.py 开始,重点查看 _recursive_get,以及 mautrix_telegram/config.py,其中 bridge.filter.mode 会在配置设置期间被复制。复现报告中所示的启动失败,并使无效的嵌套配置产生能够指出问题的错误,而不是 NoneType traceback。

由索引模型根据 Issue 内容生成。

描述

This doesn't tell me what is wrong:

Feb  3 10:15:20 integrations systemd[1]: Started Telegram Bridge.
Feb  3 10:15:22 integrations python[16389]: Traceback (most recent call last):
Feb  3 10:15:22 integrations python[16389]:   File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
Feb  3 10:15:22 integrations python[16389]:     "__main__", mod_spec)
Feb  3 10:15:22 integrations python[16389]:   File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
Feb  3 10:15:22 integrations python[16389]:     exec(code, run_globals)
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix_telegram/__main__.py", line 113, in <module>
Feb  3 10:15:22 integrations python[16389]:     TelegramBridge().run()
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/bridge/bridge.py", line 92, in run
Feb  3 10:15:22 integrations python[16389]:     self._prepare()
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/bridge/bridge.py", line 99, in _prepare
Feb  3 10:15:22 integrations python[16389]:     self.prepare_config(args.config, args.registration, args.base_config)
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/bridge/bridge.py", line 122, in prepare_config
Feb  3 10:15:22 integrations python[16389]:     self.config.update()
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 152, in update
Feb  3 10:15:22 integrations python[16389]:     self.do_update(ConfigUpdateHelper(base, self))
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix_telegram/config.py", line 146, in do_update
Feb  3 10:15:22 integrations python[16389]:     copy("bridge.filter.mode")
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 112, in copy
Feb  3 10:15:22 integrations python[16389]:     if from_path in self.source:
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 57, in __contains__
Feb  3 10:15:22 integrations python[16389]:     return self.get(key, None) is not None
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 50, in get
Feb  3 10:15:22 integrations python[16389]:     return self._recursive_get(self._data, key, default_value)
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 45, in _recursive_get
Feb  3 10:15:22 integrations python[16389]:     return self._recursive_get(next_data, next_key, default_value)
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 45, in _recursive_get
Feb  3 10:15:22 integrations python[16389]:     return self._recursive_get(next_data, next_key, default_value)
Feb  3 10:15:22 integrations python[16389]:   File "/home/telegram/tgenv/lib/python3.6/site-packages/mautrix/util/config.py", line 46, in _recursive_get
Feb  3 10:15:22 integrations python[16389]:     return data.get(key, default_value)
Feb  3 10:15:22 integrations python[16389]: AttributeError: 'NoneType' object has no attribute 'get'
Feb  3 10:15:22 integrations systemd[1]: telegram.service: Main process exited, code=exited, status=1/FAILURE
主要语言
Python
星标
249
派生
84
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

mautrix/python 的其他 Issue

查看 mautrix/python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。