Skip to content

janitor cleanup crashes when snapshot references a gateway not present in local config #5771

Closed

Description

@gjesse

janitor cleanup crashes when snapshot references a gateway not present in local config

Version: sqlmesh 0.230.1 (via tcloud 2.11.0)

Problem

Running janitor fails with SQLMeshError: Gateway '<name>' not found in the available engine adapters when the state store contains snapshots created under a gateway that isn't configured in the current environment.

The crash originates in SnapshotEvaluator.cleanup() (evaluator.py:540):

self.get_adapter(s.model_gateway)

get_adapter() raises unconditionally if the gateway key isn't found in self.adapters.

This can happen when a developer creates models using a non-default gateway in a dev environment, but that gateway config is never merged into the shared project config. The snapshots persist in the state store and block janitor for everyone.

Impact

The entire janitor batch fails — no expired snapshots in that batch get cleaned up, including ones with valid/available gateways.

Expected behavior

Janitor should skip snapshots whose gateway isn't locally configured (with a warning) and continue cleaning up the rest. These snapshots can't be cleaned up without the adapter anyway.

Suggested fix

In SnapshotEvaluator.cleanup(), filter target_snapshots against self.adapters.keys() before passing them to concurrent_apply_to_snapshots. Log a warning for any skipped snapshots so operators know they exist.

Reproduction

  1. Developer A creates models using a gateway not in the shared/main config, via a dev environment
  2. The branch is never merged; the gateway config never reaches main
  3. Developer B (or CI) runs janitor — the state store still has snapshots referencing that gateway
  4. Janitor crashes on the missing gateway

Activity

  1. gjesse commented on Apr 20, 2026

    @gjesse
    CollaboratorAuthor

    pr: #5772

  2. mday-io commented on May 22, 2026

    @mday-io
    Collaborator

    This issue is closed - CC @StuffbyYuki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions