Skip to content

Related list offers + New for a child whose FK to the parent is readonly; the created record silently loses the link #37248

Description

@sunhaolin

What happens

A record page's related list offers + New for a child whose foreign key back to the parent is readonly. The create dialog opens pre-linked (?form=new&formObject=<child>&formLink=<fk>:<parentId>), the user saves, and the record is created without the link: the server strips the readonly field on a user insert, as it should. The new record never appears in the related list the user started from, and nothing tells them why.

Repro (HotCRM, local dev)

  • crm_sales_order.crm_quote is Field.lookup('crm_quote', { readonly: true, ... }). Only a flow writes it (the accepted-quote → order flow), because one quote → one order.
  • Open any quote → right-hand 订单 / Orders related list → + → fill the form → Create.
  • Result: the order is saved with crm_quote = null, and the quote's Orders list still shows 0.
  • The server side is confirmed directly: POST /api/v1/data/crm_sales_order with crm_quote: <id> returns 201 and the stored row has crm_quote: null. The readonly rule is behaving correctly; the UI is offering a path whose link can never be saved.

Where

ui/packages/app-shell/src/views/RelatedRecordActionsBridge.tsx → resolve({ objectName, relationshipField, ... }). aff.create is objectCanCreate && createVisible: the child's create grant plus userActions.create predicates. It never looks at whether relationshipField itself is writable by the user on create.

Expected

When the child's relationshipField is readonly (or otherwise not user-writable on create), the related list should not offer + New, because a record created from it cannot belong to this parent. At minimum, the pre-link must not be silently dropped: refuse it, or say so in the dialog.

Creating the child from its own list (unlinked) stays available, so nothing a user legitimately needs is lost.

Why p1

It silently produces orphan records from the exact place that implies they will be linked. The user sees "created", the list doesn't change, and they will likely click again, creating duplicates.

Activity

  1. added
    bug
    priority:p1
    domain:ui
    on Nov 25, 2026
  2. sunhaolin commented on Nov 25, 2026

    @sunhaolin
    CollaboratorAuthor

    Seen on @objectstack/* 18.6.0 (HotCRM local dev).

  3. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    First touch 2026-11-25T07:32Z.

  4. added
    pm:queue
    on Nov 25, 2026
  5. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

    Claim: PM loop round 2 · 2026-11-25T15:13Z
    Session: session_012MmDsSBHy5paNUz6zke9Re
    Account: os-lizheng
    Branch: claude/issue-37248-related-new-readonly-fk
    Worktree: objectstack-issue-37248
    Domain: domain:ui
    Seat: repo:objectstack#6
    File surface: ui/packages/app-shell/src/views/RelatedRecordActionsBridge.tsx (the related list's create affordance in resolve), the helper that judges whether the child's relationship field is user-writable on create if one already exists beside it, a pin in ui/packages/app-shell/src/views/ (new file named after the card), one patch changeset (stop on breach; explain in the report)
    Container & model: S, mode:subagent, model: default tier — dispatch-gates.mjs --tier: "Model tier — no path-derived mandate", effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: platform code in objectstack (RelatedRecordActionsBridge.resolve offers create = objectCanCreate && createVisible and never asks whether relationshipField is writable on create) | the server already strips a readonly field on a user insert (correct, per the card's direct POST reading) | every user who presses + New on a related list whose child FK is readonly; reported on HotCRM crm_sales_order.crm_quote, 18.6.0
    Thread-read: 7155979428
    Premise: holds (measured on origin/main d88c41e: RelatedRecordActionsBridge.tsx:613 create: objectCanCreate && createVisible, no read of the relationship field's readonly)
    Pre-claim lane: ui/packages/app-shell/** — repo:objectstack lane (domain:ui file ownership); triage notice 7163749219 routes it here, serial behind #37246
    Pre-claim deps: #37246 closed (PR #37283 merged 2026-11-25); no Blocked-by: line on the card
    Prior rulings read: related,list,offers,child,whose,parent,readonly,created,record,silently,loses,link → 286 hits; ADR-0035 Decision §4, ADR-0071 Decision §1, ADR-0146 D11, ADR-0035 Decision §3, ADR-0050 Decision §3, ADR-0055 Decision §1, ADR-0155 D1, ADR-0035 Decision §5, ADR-0050 Decision §2, ADR-0061 D2 (term-generic pointers); thread: none
    Fold-or-serial: not folded with #37289 / #37290 (still pm:blocked, a different cause — the dependsOn seed, not a readonly FK; fold gate ① fails); they queue after this card on the shared file by overlap check
    Serial constraints cleared: PR #37283 (#37246, same file) merged; no open PR touches RelatedRecordActionsBridge.tsx (open-PR file census this round)

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 25, 2026
  7. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re
    os-dev-report

    {
      "issue": 37248,
      "status": "done",
      "branch": "claude/issue-37248-related-new-readonly-fk",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/37321",
      "session": "session_012MmDsSBHy5paNUz6zke9Re",
      "premise_still_valid": true,
      "summary": "Premise held on origin/main d88c41e51 (the related list's create affordance was `objectCanCreate && createVisible`, no read of the relationship field). RelatedRecordActionsBridge.resolve now withholds onCreate (no + New) when the list names a relationship field and parent id and the child's create form would not save that field. The verdict reuses the create form's own outbound filter: new `createKeepsField` in @object-ui/plugin-form = `sanitizeFormData({[fk]: …}, schema, { canEdit: fieldWriteGate(perms, obj, 'create') })`, key survives or not. Signals honoured (all the form strips on create): declared readonly/readOnly, computed:true, computed types (formula/summary/rollup/autonumber), system:true, the server-owned name roster (incl. owner_id: the create form sends a seeded owner only when the user changes it, so a pre-linked owner is dropped too), an undeclared key, and field-level security on create when a principal is loaded. Left out: readonlyWhen (record-dependent; the form's outbound filter does not read it either, so reading it here would be a second rule), and the read-only create-form UI pass (applyFieldPermissions), which asks the same field gate. Landing point: the bridge plus a new plugin-form helper, because the form's filter is not exported and app-shell must not copy it; this adds one published named export (additive) to @object-ui/plugin-form. Pin placed in views/__tests__/ beside the other bridge pins (the order named views/). Card assignee not touched. Deviation: the first push was refused by the pre-push check:commit-card-trailers (the harness attribution put a model name in Co-Authored-By); both unpublished commits were squashed and recommitted with the model-free pair before anything reached the remote.",
      "tests": "At 2e42f22fd (tree identical to the commits the runs used; the two commits were squashed into one to fix the trailer, content unchanged). New pin RelatedRecordActionsBridge.readonlyLink-37248.test.tsx: 4/4 green. Ablation (scripts/ablation-replace.mjs, anchor `&& linkSurvivesCreate` removed, anchor 1 -> 0, blob 37928e2b -> 82755ba0; vitest aliases @object-ui/* to src so no dist leg): `Tests 3 failed | 1 passed (4)`, the CONTROL the one passing; restore: blob == HEAD 37928e2b, git diff HEAD empty. Bridge + related views (RelatedRecordActionsBridge*, PageView.relatedListActions-12870, ObjectView.recordRelatedNotOnOwnList-11270, RecordDetailView*): `Test Files 112 passed (112)`, `Tests 927 passed (927)`, lock VERDICT command-exit 0. @object-ui/plugin-form full suite: `Test Files 246 passed (246)`, `Tests 2787 passed | 1 skipped (2788)`, VERDICT command-exit 0. plugin-form type-check: Done (exit 0 for that package). app-shell type-check: NOT MEASURED, reason: needs every ui package dist (395 errors, all missing-declaration noise from unbuilt siblings, none attributable to the diff's types); declared to the CI type-check lane.",
      "gates": "Local: 38 derived families (dispatch-gates.mjs --commands) at the same tree, each run with exit captured before any pipe: 38/38 EXIT=0 (incl. pnpm --dir ui exec vitest run scripts/: Test Files 172 passed | 2 skipped, VERDICT command-exit 0). --ran reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN. check-nul-bytes exit 0. overlap-check: VERDICT clean exit 0 (merges cleanly onto origin/main d88c41e51). CI check-runs on PR #37321: in_progress at report time, not awaited.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 — relay pr_create (POST pulls draft + POST issues/37321/assignees os-lizheng, one relay stroke, run 45654362236); relay comment on issue #37248 (this os-dev-report). Plus git push (not REST).",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": []
    }
  8. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

    Claim amended · 2026-11-25T16:35Z (claim 7166499014), read off PR #37321's diff:
    Clause-②: yes (widening)

    • Why: the PR adds createKeepsField to @object-ui/plugin-form's package entry (ui/packages/plugin-form/src/index.tsx, +8; new module createKeepsField.ts). That widens a published package's public surface. The claim's no was the seat's prediction; the diff is the fact.
    • File surface: adds ui/packages/plugin-form/src/createKeepsField.ts and the export line. This is the measured route the dispatch order asked for: it reuses the create form's own outbound filter (sanitizeFormData with fieldWriteGate(..., 'create')) so the list and the form never disagree, and it does not fork a second rule into app-shell.
    • Owed: an L2 at TIER_DEFAULT for the declaration, run by this seat. The changeset line is corrected in a patch round.
  9. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

    Delivered · 2026-11-25T18:20Z · PR #37321 merged; the card closed through Fixes. A record page's related list no longer offers + New when the child's create form would drop the link to the parent (readonly, computed, server-owned or closed on create). The judgement is the create form's own outbound filter, exposed as createKeepsField on @object-ui/plugin-form (Clause-②: yes (widening), L2 PASS 7168324959 plus the deltas). Owner-based related lists (owner_id) also stop offering + New, as the changeset states. pm:dispatched removed; nothing remains on this card.

  10. removed
    pm:dispatched
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:uxbugdomain:uipriority:p1

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions