Skip to content

fix(objectql): seed reference resolution falls back to matching by id#1814

Merged
os-zhuang merged 1 commit into
mainfrom
fix/seed-loader-id-resolution
Jun 14, 2026
Merged

fix(objectql): seed reference resolution falls back to matching by id#1814
os-zhuang merged 1 commit into
mainfrom
fix/seed-loader-id-resolution

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Problem

SeedLoaderService.resolveFromDatabase only matched a reference value against the target's natural-key field. A seed that wires a lookup to a real existing record by its internal id — e.g. a people field (approver/applicantuser) pointed at the current user — dangled to null when:

  • the id is not a UUID/ObjectId (so the caller's looksLikeInternalId guard didn't short-circuit and write it directly), and
  • the id isn't the target's natural key (so the name-based lookup found nothing).

This surfaced while wiring AI-built approval apps' sample rows to a real user (cloud apps#285): the approver field is a proper user lookup, the seed carries a valid user id, yet it resolved to null.

Fix

When the natural-key lookup finds nothing, try resolving the value as the target's id. Safe: an id either exists or it doesn't, so there's no risk of a false natural-key match; tenant-scoped like the primary lookup.

Notes

Small, additive change in resolveFromDatabase; covers both pass-1 and the deferred pass-2 resolution (both route through this method). Verified by typecheck; cloud-side e2e is pending the next framework bump (the local rig is currently on an unrelated newer framework commit).

🤖 Generated with Claude Code

SeedLoaderService.resolveFromDatabase only matched a reference value against the
target's natural-key field. A seed that wires a lookup to a REAL existing record
by its internal id — e.g. a people field (approver/applicant → user) pointed at
the current user — dangled to null when that id is not a UUID/ObjectId (so the
caller's `looksLikeInternalId` guard did not short-circuit) and is not the
target's natural key.

Add an id fallback: when the natural-key lookup finds nothing, try resolving the
value as the target's `id`. Safe — an id either exists or it doesn't, so there's
no risk of a false natural-key match; and it's tenant-scoped like the primary
lookup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 13, 2026 12:44pm

Request Review

@os-zhuang
os-zhuang merged commit a5878d0 into main Jun 14, 2026
12 checks passed
@os-zhuang
os-zhuang deleted the fix/seed-loader-id-resolution branch June 14, 2026 01:44
xuyushun441-sys added a commit that referenced this pull request Jun 14, 2026
* docs(skills): sync objectstack-* skills with 9.0→9.4 changes

Audited all changes from @objectstack/types@9.0.1 to 9.4.0 and updated the
six skills whose documented contracts had drifted or gained capabilities:

- ui: fix matrix report example (rows down × columns across, ADR-0021 D2) +
  drilldown; add Action opensInNewTab/newTabUrl (#1787); App.hidden (ADR-0045);
  userFilters toggle deprecation
- platform: correct namespace prose — manifest.namespace is enforced
  (ADR-0048, validateNamespacePrefix/NamespaceConflictError); split-app boot
  sequence; os package install/publish; cloud-connection; sys_metadata opt-in
- automation: inbound webhook (api) triggers + queue prerequisite (ADR-0041);
  ADR-0044 send-back-for-revision (revise/back edges, maxRevisions)
- api: document the /meta REST surface — ?preview=draft (#1763), ?package=
  (ADR-0048), /meta/doc content omission (ADR-0046)
- ai: built-in data_chat assistant + visualize_data + query-only gate
  (ADR-0040); fix stale guardrails example keys; model-registry providers
- data: seed lookup id-fallback (#1814)

query/formula/i18n skills required no changes (no contract drift in range).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: add empty changeset for docs-only skills sync

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
os-zhuang added a commit that referenced this pull request Jun 20, 2026
#2066)

Now that the SDUI renderer fixes landed in objectui (#1814), restore the
showcase features that were dropped as workarounds:

My Work — KPI hero row moves from `flex` back to an equal-width `grid`
(layout grid no longer shadowed by ObjectGrid); sidebar gains a per-user
`visible`-gated note (`user.email == 'admin@objectos.ai'` shows for the admin,
a different-email note stays hidden) demonstrating component-level role gating.

Account 360 — the History tab returns: `record:history` now self-fetches from
sys_activity field_change events (trackHistory on status/industry), so the tab
lists real audit entries instead of "No history yet".

Browser-verified on :5181: grid-cols KPI row, role-gated visibility, and the
History tab populating after an industry change. typecheck + 20 tests pass.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants