Repository navigation
Conversation
store_pipeline_log() splits user_id on the first "__" and writes namespace and user_id as separate columns, which is the documented contract in cache_base. get_pipeline_logs() compared the raw string against user_id only, so user_id="proj__u1" never matched the row it had just written: every namespaced user got an empty log list back from MemoryInspector. Split the requested id the same way and match the (namespace, user_id) pair on both backends. Rows written before the namespace column existed keep the full id in user_id with namespace='', so they are still matched when the requested id contains "__"; a bare id keeps the previous behaviour.
The fix touched two backends but the tests only exercised sqlite; mysql needs a server, so CI cannot reach that branch at all. Capture what get_pipeline_logs hands to _fetchall instead — the predicate text and the placeholder order are exactly what a half-applied change gets wrong, and a wrong order returns another tenant's rows without raising. Red on main (no namespace condition there), green with the fix. Also document the user_id contract on the mysql method, matching sqlite.
Author
|
跟进一下(不催合,只是同步状态): 这条正文最后留了一个需要你拍板的接口语义问题(不带 另外报一个我这边无法自助解决的事:本仓库 这批 PR 都已对齐 11-18 的 main( |
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.
变更
store_pipeline_log()写入时按第一个"__"把 user_id 拆成namespace与user_id两列落库(cache_base的接口注释就是这个契约),但get_pipeline_logs()拿调用方传进来的原始串直接比user_id:所以
user_id="proj__u1"永远比不过刚写进去的namespace='proj', user_id='u1'。查询侧改成同口径拆分并按(namespace, user_id)成对匹配;cache_sqlite与cache_mysql同错同改。旧库里经
_migrate_pipeline_logs_columns补列的历史行是namespace='' + 完整 user_id,所以请求带"__"时额外放行namespace='' AND user_id=<原始串>,不让改口径把老数据查丢。不带"__"的 user_id 行为不变。用户影响
MemoryInspector.get_pipeline_logs(user_id=...)是文档里给出的公开用法,多租户/多项目(proj__u1这种 SDK user_id)下按 user_id 查 pipeline 日志恒返回空列表,看起来像"这个用户没有任何 EXTRACT / SEARCH_QUERY 记录"。改后能查到自己的日志,且不会跨 namespace 串(proj__u1与other__u1各查各的)。按
request_id查询不受影响,写侧数据一直是对的 —— 坏的只有读侧这一条过滤条件。验证
tests/test_pipeline_log_user_lookup.py(5 例)tests/test_pipeline_observability.py+tests/test_op_trace_logs.py→ 27 passeduser_id="proj__u1"后get_pipeline_logs(user_id="proj__u1")→ 0 行,get_pipeline_logs(user_id="u1")→ 1 行。一个没改的点,想听你的意见
不带
"__"的 user_id 我保持了原行为(只比user_id列),这意味着get_pipeline_logs(user_id="u1")仍会同时返回namespace='proj'和namespace='other'下 user_id 都是u1的行。要不要把它也收成namespace='' AND user_id=?(即严格按租户隔离),或者反过来给get_pipeline_logs加一个显式namespace参数?这属于接口语义选择,我没有替你决定。隐私与安全
tmp_path)回滚
两处 SQL 过滤条件 + 一个测试文件,可整体 revert;表结构不变,无需迁移。