fix(PROD-2187): pull linked-content model references for --models and --models-with-deps#164
Merged
Merged
Conversation
… --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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PROD-2187
Pulling a model whose field links to another model (a
Content-type field withsettings.ContentDefinition, e.g.FooterLinks → FooterLinksLists) failed when the target didn't already have the referenced model:Neither
--modelsnor--models-with-depsfollowed model→model references, so the referenced definitions were never included in the push set.Fix
Adds
resolveReferencedModels()— a transitive, de-duplicated, cycle-safe walk overfield.settings.ContentDefinition— defined once inModelDependencyTreeBuilderand 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): newfindModelsReferencedByModelsstep so referenced models (and their containers) join the full dependency tree.Because
pushModelscreates 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
--models="FooterLinks"FooterLinks+FooterLinksLists(transitive), models only--models-with-deps="FooterLinks"Tests
model-dependency-tree-builder.test.ts: referenced model included, transitive A→B→C, unrelated excluded, cycle terminates (viabuildDependencyTree).guid-data-loader.test.ts: unit tests forresolveReferencedModels(direct/transitive/cycle/case-insensitive/unknown-name/empty-ref) + integration test throughloadGuidEntitiesproving--models="FooterLinks"returns[FooterLinks, FooterLinksLists]and leaves content/pages/containers empty.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)

🤖 Generated with Claude Code