Skip to content

fix: propagate knowledge base renames to the configuration - #11032

Open
cola0405 wants to merge 1 commit into
AstrBotDevs:masterfrom
cola0405:fix/kb-rename-config-sync
Open

cola0405 wants to merge 1 commit into
AstrBotDevs:masterfrom
cola0405:fix/kb-rename-config-sync

Conversation

@cola0405

@cola0405 cola0405 commented Nov 7, 2026 •

Copy link
Copy Markdown

Motivation / 动机

Renaming a knowledge base breaks retrieval: kb_names in the configuration still holds the old name, so get_kb_by_name() misses it and check_all_kb() skips retrieval without any error. Re-selecting the knowledge base is the only workaround.

重命名知识库后检索失效:配置里的 kb_names 仍是旧名称,get_kb_by_name() 匹配不到,check_all_kb() 直接跳过检索且不报错,必须重新选择知识库才能恢复。

Modifications / 改动点

  • knowledge_base_service.py: on rename, propagate the new name to kb_names in every config profile (deduplicated, UUID entries untouched).
    重命名时把新名称同步到每份配置的 kb_names(去重,UUID 条目保持原样)。
  • Regression test: retrieval still works after a rename.
    回归测试:改名后检索仍然可用。

Verification / 验证

English

  1. Select cola in the config, retrieval works.
  2. Rename it to cola-v2 on the knowledge base page.
  3. The config still holds the old name cola, so retrieval returns nothing until it is re-selected.

中文

  1. 在配置里选中 cola,检索正常。
  2. 在知识库页改名为 cola-v2。
  3. 配置里仍是旧名称 cola,检索失效,重新选择后才恢复。
1. Selected cola 2. Renamed to cola-v2 3. Config keeps cola

Test Results / 测试结果

tests/unit/test_kb_rename_propagates_to_config.py   5 passed
ruff format --check .                              546 files already formatted
ruff check .                                       All checks passed!

Checklist / 检查清单

  • This is NOT a breaking change. / 这不是破坏性变更。
  • N/A, no new feature. / 无新功能。
  • Tested, with steps and screenshots above. / 已测试,上方附验证结果与截图。
  • No user-facing docs affected. / 无涉及用户文档的变更。
  • No new dependencies. / 未引入新依赖。
  • No malicious code. / 未引入恶意代码。

Retrieval resolves knowledge bases by name through `kb_names` in the
configuration, but renaming a knowledge base only updated the database
record. Every subsequent lookup missed the renamed knowledge base and
`check_all_kb()` treated it as empty, silently skipping retrieval until
the user re-selected it in the dashboard.

Propagate the new name to every configuration profile that still
references the old one so retrieval keeps working after a rename.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. Renaming a knowledge base now rewrites and saves its name in every configuration profile that selected it. If that mapping is wrong, reverting the code will not restore the saved profile values; they are bounded and can be corrected by updating the configuration.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@Soulter Soulter moved this to In Progress in AstrBot Roadmap Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant