Skip to content

Fix: create_external_models misclassifies cross-repo models as external#5745

Open
gabepesco wants to merge 1 commit intoSQLMesh:mainfrom
gabepesco:fix/multi-repo-create-external-models
Open

Fix: create_external_models misclassifies cross-repo models as external#5745
gabepesco wants to merge 1 commit intoSQLMesh:mainfrom
gabepesco:fix/multi-repo-create-external-models

Conversation

@gabepesco
Copy link

@gabepesco gabepesco commented Mar 26, 2026

Resolves #5326

Description

In a multi-repo setup, create_external_models partitions models per-config before passing them to create_external_models_file. This caused dependencies that belong to another repo (e.g. bronze.a referenced by silver.c in repo_2) to appear missing from the current config's model set and be incorrectly classified as external.

The fix adds an all_models parameter to create_external_models_file that represents the full set of loaded models across all repos. Dependency resolution uses this complete set, so cross-repo internal models are never mistaken for external ones. The per-config models argument is still used to scope which models' dependencies are written to each repo's external_models.yaml.

Test Plan

Added test_multi_repo_create_external_models in tests/core/integration/test_multi_repo.py using the existing examples/multi fixture. The test verifies that after create_external_models(), no "Unable to get schema" warnings are emitted for cross-repo models, and that plan still resolves all models as internal (no new snapshots treated as external).

Confirmed the test fails without the fix and passes with it. Ran full regression on tests/core/test_schema_loader.py and tests/core/integration/test_multi_repo.py, all passing. I also monkey patched it into my own pipeline, and the warning was gone and no other issues occurred.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO

…al (SQLMesh#5326)

In a multi-repo setup, `create_external_models` partitions models per-config
before passing them to `create_external_models_file`. This caused dependencies
that belong to another repo (e.g. `bronze.a` referenced by `silver.c` in repo_2)
to appear missing from the current config's model set and be incorrectly
classified as external.

The fix adds an `all_models` parameter to `create_external_models_file` that
represents the full set of loaded models across all repos. Dependency resolution
uses this complete set, so cross-repo internal models are never mistaken for
external ones. The per-config `models` argument is still used to scope which
models' dependencies are written to each repo's `external_models.yaml`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gabepesco gabepesco changed the title Fix: create_external_models misclassifies cross-repo models as external (#5326) Fix: create_external_models misclassifies cross-repo models as external Mar 26, 2026
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.

In a multi repo the create_external_models command has problems with models being defined in one project and selected from in another project

1 participant