Skip to content

fix(PROD-2187): pull linked-content model references for --models and --models-with-deps#164

Merged
jules-exel merged 1 commit into
mainfrom
fix/PROD-2187-model-depths
Jun 16, 2026
Merged

fix(PROD-2187): pull linked-content model references for --models and --models-with-deps#164
jules-exel merged 1 commit into
mainfrom
fix/PROD-2187-model-depths

Conversation

@jules-exel

@jules-exel jules-exel commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

PROD-2187

Pulling a model whose field links to another model (a Content-type field with settings.ContentDefinition, e.g. FooterLinks → FooterLinksLists) failed when the target didn't already have the referenced model:

✗ model FooterLinks — Unable to save the model.
404 "Definition for setting FooterLinksLists (for reference name FooterLinksLists) not found"

Neither --models nor --models-with-deps followed model→model references, so the referenced definitions were never included in the push set.

Fix

Adds resolveReferencedModels() — a transitive, de-duplicated, cycle-safe walk over field.settings.ContentDefinition — defined once in ModelDependencyTreeBuilder and used on both paths:

  • --models (guid-data-loader): expands the requested models to include referenced models. Still models-only (no content/pages/containers/assets).
  • --models-with-deps (ModelDependencyTreeBuilder): new findModelsReferencedByModels step so referenced models (and their containers) join the full dependency tree.

Because pushModels creates all model stubs before applying fields, the referenced model exists on the target by the time the referencing model's fields are saved — so no more 404.

Behaviour

Flag Result
--models="FooterLinks" FooterLinks + FooterLinksLists (transitive), models only
--models-with-deps="FooterLinks" same + full renderable tree (containers, content, pages, assets…)

Tests

  • model-dependency-tree-builder.test.ts: referenced model included, transitive A→B→C, unrelated excluded, cycle terminates (via buildDependencyTree).
  • guid-data-loader.test.ts: unit tests for resolveReferencedModels (direct/transitive/cycle/case-insensitive/unknown-name/empty-ref) + integration test through loadGuidEntities proving --models="FooterLinks" returns [FooterLinks, FooterLinksLists] and leaves content/pages/containers empty.
  • Full suite: 1729 passing, typecheck clean.

Scope note

This PR is intentionally limited to model dependency resolution. The other PROD-2187 defects surfaced during testing — false-negative model creates, silent-wedge missing mappings, failed-update-reported-as-success will be address later

Command used:
node dist/index.js --sourceGuid="cba4afff-us2" --targetGuid="0ec344e7-us2" --locales="en-us" --models-with-deps="FooterLinks"

Outcome (previously failed to create model)
image

🤖 Generated with Claude Code

… --models-with-deps

A model whose field links to another model (Content-type field with
settings.ContentDefinition, e.g. FooterLinks -> FooterLinksLists) failed to
push to a target that didn't already have the referenced model, with a 404
"Definition for setting X not found". Neither --models nor --models-with-deps
followed model-to-model references, so the referenced definitions were never
included in the push set.

Add resolveReferencedModels(), a transitive, de-duplicated, cycle-safe walk over
settings.ContentDefinition, and apply it on both paths:
- --models (guid-data-loader): expand the requested models to include referenced
  models; still models-only (no content/pages/containers).
- --models-with-deps (ModelDependencyTreeBuilder): new findModelsReferencedByModels
  step so referenced models (and their containers) join the full dependency tree.

Because pushModels creates all model stubs before applying fields, the referenced
model exists on the target by the time the referencing model's fields are saved.

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

@5PK 5PK left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@jules-exel jules-exel merged commit d69d61f into main Jun 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants