Repository navigation
Conversation
后端: - model.ResolveOwnerID:principal 用户 id → owner_id(匿名落系统占位 0); model.OwnerNames:按 id 批量解析 bi_user.username(刻意不过滤禁用/软删, 「禁用不删归属」)。 - 六个 create 路径(datasource/dataset/chart/dashboard/dashboard-folder/alert) 由 handler 从上下文 principal 注入归属;dashboard/folder/alert 此前列留 NULL,现在统一打 owner_id。 - middleware.OptionalBearer 挂在 /api 组:资源端点无 Authorization 头保持 匿名(L0 口径不变);携带**无效**凭证 fail-closed 20200(静默降级成匿名 会让过期 token 的创建悄悄丢归属)。 - datasource/dataset/chart/dashboard 列表出口回填 owner_name(可空, owner_id=0/NULL 为 null),单个 GET/POST/PUT 响应暂不回填(恒 null)。 契约:openapi.yaml 四个实体 schema 增 owner_name(nullable、不进 required), gen_types.go/.ts 手工同步(可选字段语义,与生成器口径一致)。 前端:数据集/图表/仪表盘列表加「创建人」列,无归属显示「—」;i18n 增 common.owner(zh/en)。 测试:ResolveOwnerID/OwnerNames 单测、六域 INSERT 携带 owner_id 列断言、 列表回填 sqlmock 用例、OptionalBearer 三分支中间件用例、contract_parity chartCreateIn 转有意裁剪档并注明原因;go test -race 全绿;pnpm build:check (biome+tsc+956 vitest)全绿。真实浏览器 E2E:注册 bootstrap admin → 登录 创建仪表盘/数据源/数据集 → 列表创建人显示用户名;登出匿名创建显示「—」; 无效 token 401。 已知边界:/api/datasets/import 与 /replace(multipart 非泛型路由)本次未接 principal,仍落 NULL——属 #138/#201 的上传链路,留给评审裁夺。
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.
做了什么(issue #220 / R-95)
model.ResolveOwnerID把 handler 注入的 principal 用户 id 换算成 owner_id(匿名 → 系统占位 0,口径与 [P0] R-22 三表欠账:bi_datasource/bi_dataset/bi_chart 落 owner_id #171 一致)。六个 create 路径(datasource / dataset / chart / dashboard / dashboard-folder / alert)全部接通——dashboard / folder / alert 此前连占位 0 都不写(列留 NULL),现已统一。传递方式按 issue 建议实现:handler 从middleware.PrincipalFrom取值塞进 service 输入,service 不读 gin context。middleware.OptionalBearer挂在/api组。无Authorization头 → 匿名放行(L0 开放口径不变);携带有效凭证 → principal 注入上下文;携带无效凭证 → fail-closed 20200(静默降级成匿名会让过期 token 的创建悄悄丢归属,正是 R-95 要消灭的状态)。这是一个需要评审确认的口径决策:无效 token 从「被忽略」变为 401。owner_name(可空;owner_id=0/NULL → null)。名字解析model.OwnerNames只按 id IN 过滤,刻意不过滤禁用/软删(验收 4「禁用不删归属」)。单个 GET/POST/PUT 响应共享同一 schema、暂不回填(恒 null)。api/openapi.yaml四个实体 schema 增owner_name(nullable,不进 required,= 可选字段);gen_types.go/gen_types.ts手工同步为可选语义(omitempty/?:),api-gen 前端半步已知损坏(见 troubleshooting)。common.owner,zh/en),无归属显示「—」。怎么验证的
go test -race ./...全绿;前端pnpm build:check(biome + tsc --noEmit + 956 vitest)全绿。ResolveOwnerID纯函数(0/7/-3)、OwnerNames(批量解析、缺失 id 不进 map、只按 id 过滤)、六域 create 的 INSERT 语句携带owner_id列断言(dashboard/folder/alert 为新增列断言)、datasource 列表回填 sqlmock 用例(owner_id=1 → alice、owner_id=0 → null)、OptionalBearer三分支(无头匿名 / 有效注入 / 无效 20200)、contract_parity_test的chartCreateIn↔entity.Chart转为有意裁剪档并注明原因。make serve形态,远端 insight_dev 库):bootstrap 注册 admin(r95admin)→ 登录后建仪表盘(UI)/ 数据源(API)/ 数据集(API)→ 三个列表的创建人列均显示r95admin(截图核对);登出(匿名)创建的仪表盘创建人显示「—」;存量行(迁移前的仪表盘001)显示「—」。API 三场景断言:登录创建owner_id=1、匿名创建owner_id=0、无效 token 返回 20200。测试产物已清理。已知边界 / 请评审关注
/api/datasets/import与/replace(multipart 非泛型路由)未接 principal,导入的数据集仍落 NULL owner——属 本地 Excel/CSV 拖拽上传即时分析 #138/[P0] R-85 本地上传开箱可用:抽取存储零配置 + 上限与推断口径写明 #201 上传链路,请评审裁夺是否本条收口。zz_realpg先例补TEST_DATABASE_URL门控用例。first-run.md「升级前创建的资源创建人不可考」的说明归 [P0] R-103 文档口径收口:清除 9 处「无登录、无鉴权」+ first-run 章节 + 配置字典 #228(R-103)的文档批次,本条未创建该文件。