Repository navigation
fix(automation):本地数据库配置对齐后端默认值,DB 断言兼容 ENUM 大小写 - #403
Merged
Merged
Conversation
added 2 commits
October 26, 2026 19:37
## 修改
- `automation/config/local/config.yaml`:database 改为 `root:123456@127.0.0.1:3306/helpdesk_724`,
与 backend 的 `DATABASE_URL` 默认值一致,`REAL_DB_ASSERTIONS=1` 可直接使用。
原配置是 `root:root@.../openrobot`,与本地/后端实际使用的库对不上,导致数据库断言只能关闭。
- `automation/src/assertions/database.py`:`tasks.status` 等列在 MySQL 中是 ENUM,落库值为大写
(NEW / IN_PROGRESS / PROBLEM),而接口返回小写(new / in_progress / problem),原 `!=` 比较必然失败。
枚举字段(status / task_type / priority / ticket_type)改为大小写不敏感比较,其余字段仍严格比较。
## 验证
- `REAL_DB_ASSERTIONS=1 USE_MOCK=0 pytest tests/real -q` → 10 passed(含 tasks 表落库核对)
- `pytest src/assertions -q` → 27 passed
## 背景
本次调试修复前的报错:
Task 60 field 'status' mismatch: expected 'new', got 'NEW'
row={'id': 60, 'status': 'NEW', 'created_by': 'user_admin', ...}
覆盖 10 条业务场景中剩余部分的设计方案,本期不实施,仅留档。
内容:
- 范围划分:②⑤⑧⑨ 纳入(纯接口),⑥⑩(依赖 AI 服务 8401)、⑦附件(依赖 MinIO)暂不做
- 已核实的接口契约(避免后续重复调研):
- `PATCH /api/tasks/{id}/assign` 的 `user_id` 是 **query 参数**,不是 body
- `POST /{id}/re-dispatch` 依赖 Redis 发布事件,本地无 Redis 时只断言 DB 状态
- `POST /{id}/relations` 需 `backend:tasks:operate` 权限,relation_type 三值:
predecessor / duplicate / subtask
- 代理关系**无任何创建 API**,`create_task_proxy_relation.py` 只建表不插数据,
用例需直接向 `task_proxy_relation` 表插入
- `set-step-time` 仅对 `escalate_count > 0` 的工单生效,本期不测
- 用例清单 7 条 + 文件划分 + 实现步骤 + 风险表
文档顶部已标注"待排期,尚未实施",避免被误认为已批准。
Rosshow
approved these changes
Oct 28, 2026
Rosshow
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改
automation/config/local/config.yaml:database 改为root:123456@127.0.0.1:3306/helpdesk_724, 与 backend 的DATABASE_URL默认值一致,REAL_DB_ASSERTIONS=1可直接使用。 原配置是root:root@.../openrobot,与本地/后端实际使用的库对不上,导致数据库断言只能关闭。automation/src/assertions/database.py:tasks.status等列在 MySQL 中是 ENUM,落库值为大写 (NEW / IN_PROGRESS / PROBLEM),而接口返回小写(new / in_progress / problem),原!=比较必然失败。 枚举字段(status / task_type / priority / ticket_type)改为大小写不敏感比较,其余字段仍严格比较。验证
REAL_DB_ASSERTIONS=1 USE_MOCK=0 pytest tests/real -q→ 10 passed(含 tasks 表落库核对)pytest src/assertions -q→ 27 passed背景
本次调试修复前的报错:
Task 60 field 'status' mismatch: expected 'new', got 'NEW'
row={'id': 60, 'status': 'NEW', 'created_by': 'user_admin', ...}