Skip to content

Commit 2a9b908

Browse files
committed
fix: Skip missing tenant schemas in demo user seeding
SeedDemoUsers iterates all tenants from DEMO_OPERATOR_TENANT (comma- separated). When a listed tenant has not been provisioned in the current environment (e.g. payg_energy on demo), the schema lookup fails with ErrTenantSchemaNotProvisioned and aborts the entire seeding operation - even though earlier tenants (volterra_energy) were seeded successfully. Skip tenants with missing schemas instead of failing. Log a warning so the skip is visible in deploy logs without blocking the pipeline.
1 parent b3b0bd5 commit 2a9b908

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

services/identity/bootstrap/bootstrap.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/meridianhub/meridian/services/identity/domain"
1919
"github.com/meridianhub/meridian/shared/pkg/credentials"
2020
"github.com/meridianhub/meridian/shared/platform/auth"
21+
"github.com/meridianhub/meridian/shared/platform/db"
2122
"github.com/meridianhub/meridian/shared/platform/tenant"
2223
)
2324

@@ -213,6 +214,16 @@ func SeedDemoUsers(ctx context.Context, repo domain.Repository) error {
213214

214215
for _, u := range users {
215216
if err := seedDemoUser(ctx, repo, u); err != nil {
217+
// Skip tenants whose schemas have not been provisioned.
218+
// DEMO_OPERATOR_TENANT may list multiple tenants but not all
219+
// of them exist in every environment (e.g. payg_energy is
220+
// configured but only volterra_energy is provisioned on demo).
221+
if errors.Is(err, db.ErrTenantSchemaNotProvisioned) {
222+
slog.WarnContext(ctx, "demo user seeding skipped: tenant schema not provisioned",
223+
"email", u.Email,
224+
"tenant", u.TenantID)
225+
continue
226+
}
216227
return fmt.Errorf("seeding demo user %s: %w", u.Email, err)
217228
}
218229
}

0 commit comments

Comments
 (0)