[Data Connect] MISSING_JOIN_TABLE_KEY false positive on tables with an explicit id key referenced by other tables

未关闭
#11,348 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

Start by tracing the Data Connect schema compilation path used by firebase dataconnect:compile and find where MISSING_JOIN_TABLE_KEY is detected; the issue does not name implementation files or tests. Check how the detection handles explicit @table(key: ["id"]) declarations and references from other tables, then add coverage for the Enrollment schema. Done when that schema no longer produces the warning while genuine join tables still do.

由索引模型根据 Issue 内容生成。

描述

api: dataconnect Needs: Author Feedback no-recent-activity type: bug
[REQUIRED] Environment info

firebase-tools: 15.34.1 (Data Connect emulator / toolkit 3.4.24)

Platform: macOS 26.4, Node 22

[REQUIRED] Test case

A table with two required @ref fields that is an entity in its own right, not a join table. It has its own id key, the pair of parents is intentionally not unique, and another table references it by id:

type User @table { name: String! }
type Plan @table { title: String! }

# A user can enroll in the same plan more than once (re-enrollment),
# so (user, plan) is not unique and cannot be the primary key.
type Enrollment @table(key: ["id"]) {
  id: UUID! @default(expr: "uuidV4()")
  user: User!
  plan: Plan!
  startDate: Date!
  status: String!
}

# Other tables reference an enrollment by its id.
type Session @table {
  enrollment: Enrollment
  performedAt: Timestamp!
}

The same thing happens for other common shapes, e.g. a "notes about a user written by an author" table (many notes per author/user pair), or an ordered "exercises in a workout" table where the same exercise can appear twice.

[REQUIRED] Steps to reproduce
  1. Use the schema above.
  2. Run firebase deploy --only dataconnect (also shown by firebase dataconnect:compile).
[REQUIRED] Expected behavior

No MISSING_JOIN_TABLE_KEY warning for Enrollment. It explicitly declares key: ["id"], and another table references that key, so it can't be a join table missing its composite key. Alternatively, a way to acknowledge the warning per table (e.g. a schema-level opt-out) so it doesn't show on every deploy.

[REQUIRED] Actual behavior

Every deploy lists the table as an insecure operation or risky change and asks for acknowledgement:

MISSING_JOIN_TABLE_KEY  schema/....gql: On Enrollment: This table looks like a join table, but it is missing the composite primary key definition.
Workaround: Add `@table(key: ["plan", "user"])` to the type.
Reason: A join table must have a composite primary key that consists of two foreign keys.

Following the suggested workaround would be wrong here. It would break re-enrollment, drop the id that Session references, and require a primary-key migration on a populated table.

Related: #9630 (@view false positive, fixed in v15.3.0) and #9762 (3-column composite key false positive). In both, a maintainer confirmed the warning is non-blocking and shouldn't trigger in those cases.

主要语言
TypeScript
星标
4.5k
派生
1.3k
平均合并
2 天 18 小时
30 天内合并 PR
93

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-tools 的其他 Issue

查看 firebase/firebase-tools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。