Skip to content

fix: wire HostTenantMapping.Meta.database in _setup_redis#4

Merged
aradng merged 1 commit into
mainfrom
fix/host-tenant-mapping-db
Jun 7, 2026
Merged

fix: wire HostTenantMapping.Meta.database in _setup_redis#4
aradng merged 1 commit into
mainfrom
fix/host-tenant-mapping-db

Conversation

@aradng

@aradng aradng commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Bug

Follow-up to #3. With the cache_enabled gate fixed, the boot-time Migrator().run() actually executes — and immediately crashes the app lifespan on any deployment where redis requires AUTH:

redis.exceptions.AuthenticationError: Authentication required.
ERROR:    Application startup failed. Exiting.

HostTenantMapping declares its own class Meta: model_key_prefix = "host_mapping", which breaks the attribute chain to BaseCache.Meta, so its _meta.database resolves at import time to aredis_om.get_redis_connection()REDIS_OM_URL env or unauthenticated localhost:6379. _setup_redis wires BaseCache, BaseTenantSettingCache and the tenant cache, but never HostTenantMapping.

Observed connection per registered model before the fix:

HostTenantMapping        -> localhost 6379  pw: False   ← stray
BaseModelCache           -> redis     6379  (configured)
ProductCache             -> redis     6379  (configured)
CurveGraphContextCache   -> redis     6379  (configured)

Fix

One line: assign the configured connection to HostTenantMapping.Meta.database alongside the existing assignments. Verified live that HostTenantMapping.db() rebinds from localhost:6379 to the configured host after the assignment.

🤖 Generated with Claude Code

HostTenantMapping defines its own Meta (model_key_prefix override), so it
never chains to BaseCache.Meta.database and its db() resolves to aredis_om's
import-time default (localhost:6379, unauthenticated). On deployments where
redis requires AUTH this crashes the boot-time Migrator with
AuthenticationError as soon as the cache_enabled gate (fixed in #3) lets it
run.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@aradng aradng force-pushed the fix/host-tenant-mapping-db branch from 780cbf9 to 6a13ec3 Compare June 7, 2026 01:30
@aradng aradng merged commit 1984c6e into main Jun 7, 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.

1 participant