Skip to content

feat(lint): 视图 searchableFields 按运行时同一套判定做构建期校验 —— lookup 笔误在 validate 期就报错,而非运行时 400 (#4830) - #4844

Merged
baozhoutao merged 1 commit into
mainfrom
claude/issue-4830-searchablefields-type-validation
Aug 3, 2026
Merged

feat(lint): 视图 searchableFields 按运行时同一套判定做构建期校验 —— lookup 笔误在 validate 期就报错,而非运行时 400 (#4830)#4844
baozhoutao merged 1 commit into
mainfrom
claude/issue-4830-searchablefields-type-validation

Conversation

@baozhoutao

Copy link
Copy Markdown
Contributor

Fixes #4830

问题

视图 searchableFields 声明了不可搜索类型字段(如 lookup)时,compile/validate 全绿,但 Console 工具栏搜索把声明逐字回显为 $searchFields,#4254 入口闸按对象的可搜索集合判定后整条查询 400 INVALID_FIELD——任何角色敲第一个字符即整列表翻车,纯声明层笔误三道关全放行。

修复(issue 方案 1,declared = enforced)

新增 lint 规则 searchable-field-unsearchable(error 级),对四个视图级 narrowing 面(对象内建 listViews、defineView 的 list/listViews、react 页面 ListView searchableFields)按运行时同一个 resolveSearchFieldResolution(@objectstack/spec/data)做构建期判定,单一事实源、不复制类型清单。

  • auto 源:被 auto-default 拒绝的类型/hidden/审计列报 error(lookup 附「镜像到本对象 text/formula 字段」处方);
  • declared 源:超出对象声明集合的条目报 error(视图只能收窄);
  • 对象 canonical 集合维持只查存在性(运行时按存在过滤,不按类型过滤,构建期按类型拒绝会误伤运行时接受的元数据,ADR-0072 D1);
  • 注册表系统列在 narrowing 中跳过判定(元数据对 linter 不可见,宁漏报不误报,均有测试钉住);
  • 特意钉住的运行时一致性:对象把 json/lookup 显式声明进自身 searchableFields 后,视图回显它保持全绿(运行时确实接受)。

测试

packages/lint:970 个测试全过(新增 9 个:issue 复现用例、declared 源越界、hidden、系统列 declared 存在性 stub 一致性、canonical 不查类型等),tsc --noEmit 干净。

跨对象路径的能力缺口另拆 #4840(未指派)。

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 3, 2026 9:48am

Request Review

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/lint.

2 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/automation/hook-bodies.mdx (via @objectstack/lint)
  • content/docs/permissions/authorization.mdx (via @objectstack/lint)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@baozhoutao
baozhoutao marked this pull request as ready for review August 3, 2026 10:03
@baozhoutao
baozhoutao added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit 8e53e5d Aug 3, 2026
21 checks passed
@baozhoutao
baozhoutao deleted the claude/issue-4830-searchablefields-type-validation branch August 3, 2026 10:13
…e 期就报错,而非运行时 400 (#4830)

视图级 searchableFields 会被客户端逐字回显为 $searchFields,#4254 入口闸按
resolveSearchFieldResolution 判定后整条查询 400 INVALID_FIELD;此前
compile/validate 只查存在性,类型笔误全绿放行。

新规则 searchable-field-unsearchable(error):对象内建 listViews、defineView
的 list/listViews、react <ListView> 四个 narrowing 面,直接消费运行时同一个
resolveSearchFieldResolution(@objectstack/spec/data),不复制类型清单,
declared = enforced。对象自身 canonical 集合维持只查存在性(运行时按存在过滤、
不按类型过滤,构建期拒绝会误伤运行时接受的元数据,ADR-0072 D1)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compiler/validate: view searchableFields not validated against searchable field types — a declaration typo 400s the whole list at runtime

1 participant