Failing to set path of root controller leads to unhelpful error message

未关闭 适合新手
#416 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 fastcs/transports/epics/util.py 和 fastcs/transports/epics/ca/util.py 开始,沿着 traceback 中显示的验证路径进行排查。使用 issue 中的示例复现未设置 set_path() 的 controller,然后确认该故障解释的是缺少 path,而不是暴露 IndexError。考虑相同的行为是否也与其他 transport 有关,因为报告并未确认其他 transport 存在这种情况。

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

描述

bug

If you create a controller but do not call controller.set_path() on it, the error message created is somewhat unhelpful:

Steps To Reproduce

from fastcs.attributes import AttrR
from fastcs.controllers import Controller
from fastcs.datatypes import Int
from fastcs.launch import FastCS
from fastcs.transports.epics.ca.transport import EpicsCATransport


class TemperatureController(Controller):
    devid = AttrR(Int())


epics_ca = EpicsCATransport()
controller = TemperatureController()
# controller.set_path(["DEMO"])   # Uncomment this line and it will execute
fastcs = FastCS(controller, [epics_ca])

if __name__ == "__main__":
    fastcs.run()

The error printed is:

Traceback (most recent call last):
  File "/workspaces/fastcs-bacnet/mytest.py", line 18, in <module>
    fastcs.run()
  File "/cache/venv-for/scratch/eyh46967/dev/bacnet/fastcs-bacnet/lib/python3.12/site-packages/fastcs/control_system.py", line 85, in run
    self._loop.run_until_complete(serve)
  File "/root/.local/share/uv/python/cpython-3.12.13-linux-x86_64-gnu/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/cache/venv-for/scratch/eyh46967/dev/bacnet/fastcs-bacnet/lib/python3.12/site-packages/fastcs/control_system.py", line 147, in serve
    transport.connect(controller_apis=self.controller_apis, loop=self._loop)
  File "/cache/venv-for/scratch/eyh46967/dev/bacnet/fastcs-bacnet/lib/python3.12/site-packages/fastcs/transports/epics/ca/transport.py", line 42, in connect
    validate_ca_id(api)
  File "/cache/venv-for/scratch/eyh46967/dev/bacnet/fastcs-bacnet/lib/python3.12/site-packages/fastcs/transports/epics/ca/util.py", line 26, in validate_ca_id
    validate_epics_pv_id(controller_api, transport_label="EPICS CA id", id_re=_CA_ID_RE)
  File "/cache/venv-for/scratch/eyh46967/dev/bacnet/fastcs-bacnet/lib/python3.12/site-packages/fastcs/transports/epics/util.py", line 35, in validate_epics_pv_id
    name = controller_api.path[0]
           ~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Acceptance Criteria

  • A more informative error message is displayed

Please note I've only tested this with the "EpicsCATransport", I don't know what exactly happens with other Transports.

主要语言
Python
星标
6
派生
8
平均合并
3 天 22 小时
30 天内合并 PR
3

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

DiamondLightSource/fastcs 的其他 Issue

查看 DiamondLightSource/fastcs 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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