#8597·sqlfluff

dbt templater fails with `DbtCatalogIntegrationNotFoundError` when using `catalogs.yml`

Author: jussapaavoCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbug

Search before asking

  • I searched the issues and found no similar issues.

What Happened

(disclaimer: used AI for debugging and bug description, but everything has been reviewed and verified by me)

With the dbt templater, sqlfluff lint fails for the whole project if any model sets catalog_name to a catalog defined in catalogs.yml. The failure happens while dbt parses the project, before any file is linted. Excluding the file or using .sqlfluffignore doesn't help.

The dbt CLI (dbt compile, dbt run, dbt build) works fine on the same project.

Root cause: the dbt CLI loads catalogs.yml and registers each catalog with the adapter before parsing:

  • It calls load_catalogs_v2() or load_catalogs(), then adapter.bridge_v2_catalog() and adapter.add_catalog_integration().
  • This happens in dbt/cli/requires.py::setup_manifest and dbt/parser/manifest.py::parse_manifest.

DbtTemplater does none of this. It calls register_adapter() in dbt_config and then ManifestLoader.get_full_manifest() in dbt_manifest. The adapter therefore only knows its built-in catalogs (info_schema and managed_iceberg for BigQuery). While parsing each node, dbt calls adapter.build_catalog_relation(), which asks the adapter for the custom catalog and fails because it was never registered.

This affects both the v1 catalogs.yml format and the v2 format (flags.use_catalogs_v2: true), because the templater skips both loading paths.

Expected Behaviour

sqlfluff lint compiles the project the same way dbt compile does, including catalogs from catalogs.yml, and lints the models normally.

Observed Behaviour

Got error:

=== [dbt templater] Sorting Nodes...
User Error: dbt failed during project compilation. Consider  running  `dbt debug` or `dbt compile` to get more information from dbt. dbt.adapters.catalogs._exceptions.DbtCatalogIntegrationNotFoundError: Runtime Error
  Catalog not found.Received: my_catalogExpected one of: info_schema, managed_iceberg?

How to reproduce

  1. Create a dbt project with these files.

    dbt_project.yml:

    yaml
    name: "example"
    version: "1.0.0"
    config-version: 2
    profile: "example"
    flags:
      use_catalogs_v2: true

    catalogs.yml:

    yaml
    catalogs:
      - name: my_catalog
        type: biglake_metastore
        table_format: iceberg
        config:
          bigquery:
            external_volume: 'gs://my-bucket'
            file_format: parquet

    models/my_model.sql:

    sql
    {{ config(
        materialized = 'table',
        catalog_name = 'my_catalog',
        storage_uri = 'gs://my-bucket/my_model',
    ) }}
    
    SELECT 1 AS id
  2. Add a BigQuery profile named example to ~/.dbt/profiles.yml.

  3. Run dbt compile. It succeeds.

  4. Run sqlfluff lint models/my_model.sql. It fails with the error above.

Workaround: a sitecustomize.py placed on PYTHONPATH that wraps dbt.adapters.factory.register_adapter and registers the catalogs itself. With it, linting works:

python
import contextlib

from dbt.adapters import factory
from dbt.adapters.catalogs import DbtCatalogIntegrationAlreadyExistsError
from dbt.config.catalogs import load_catalogs_v2
from dbt.config.runtime import RuntimeConfig

_original = factory.register_adapter


def _register_adapter_with_catalogs(config, mp_context, adapter_registered_log_level=None):
    _original(config, mp_context, adapter_registered_log_level)
    if not isinstance(config, RuntimeConfig):
        return
    adapter = factory.get_adapter(config)
    for catalog in load_catalogs_v2(config.project_root, config.project_name, config.cli_vars):
        with contextlib.suppress(DbtCatalogIntegrationAlreadyExistsError):
            adapter.add_catalog_integration(adapter.bridge_v2_catalog(catalog))


factory.register_adapter = _register_adapter_with_catalogs

Suggested fix: in DbtTemplater.dbt_manifest, before calling ManifestLoader.get_full_manifest(), mirror what setup_manifest does:

  • If use_catalogs_v2 is set, load the catalogs with load_catalogs_v2 and register each one via bridge_v2_catalog and add_catalog_integration.
  • Otherwise, load them with load_catalogs and register each one's active write integration.

Dialect

bigquery

Version

  • sqlfluff 4.3.0
  • sqlfluff-templater-dbt 4.3.0
  • dbt-core 1.12.4
  • dbt-adapters 1.24.5
  • dbt-bigquery 1.12.0
  • Python 3.13

Configuration

.sqlfluff:

ini
[sqlfluff]
dialect = bigquery
templater = dbt
max_line_length = 120
max_parse_depth = 510

[sqlfluff:templater:dbt]
project_dir = data

The rest of our config (rule exclusions and layout/capitalisation settings) doesn't affect this; the failure occurs before any rules run.

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct