Skip to content

Require default_team_id when provisioning a new org#890

Merged
benben merged 1 commit into
mainfrom
ben/default-team-id-mandatory
Jul 3, 2026
Merged

Require default_team_id when provisioning a new org#890
benben merged 1 commit into
mainfrom
ben/default-team-id-mandatory

Conversation

@benben

@benben benben commented Jul 3, 2026

Copy link
Copy Markdown
Member

Why

Pull-based compute billing keys usage buckets by team_id (the org's default team). The default_team_id column shipped optional/non-breaking in #867 so existing orgs could be backfilled first — that backfill is done, so new orgs must now carry it from birth.

What

  • Provisioning a NEW org without default_team_id → 400 (ErrDefaultTeamIDRequired). The check runs inside the provision transaction (only the store knows whether the org exists), so a rejected request creates nothing — no org, no warehouse, no root user.
  • Re-provisioning an EXISTING org without the field stays valid: the stored value is kept (set-only, never wiped by omission), so idempotent re-PUTs of backfilled orgs keep working.
  • Admin PUT /orgs/:id set/clear behavior is unchanged (operator escape hatch).

Tests

  • Unit: TestProvisionNewOrgRequiresDefaultTeamID (400 + nothing created, error names the field), TestReprovisionExistingOrgKeepsDefaultTeamID (existing org keeps value on omission); fake store mirrors the real transaction semantics.
  • e2e (harness.sh): default_team_id_optionaldefault_team_id_mandatory — both ducklings provision WITH a team id and round-trip it via GET /orgs/:id, a brand-new org WITHOUT one is rejected with 400 naming the field and GET /orgs/:id stays 404, and the admin PUT set/clear path now restores the provisioned value so the org stays contract-conformant. All harness provision bodies (cnpg, ext, resilience) carry default_team_id.

🤖 Generated with Claude Code

Every org must carry its default PostHog team id from birth: pull-based
compute billing keys usage buckets by team_id, and all pre-existing orgs
have been backfilled. Provisioning a NEW org without default_team_id now
fails with 400 (ErrDefaultTeamIDRequired, decided inside the provision
transaction so nothing is created); re-provisioning an EXISTING org
without the field stays valid and keeps the stored value (set-only,
never a wipe). The admin PUT set/clear escape hatch is unchanged.

e2e: the default_team_id_optional assertion becomes
default_team_id_mandatory — both ducklings now provision WITH a team id
and round-trip it, a new org WITHOUT one must be rejected creating
nothing, and the admin PUT set/clear path restores the provisioned
value afterwards. All harness provision bodies carry default_team_id.
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Test Impact Plan

Deterministic summary of how this PR changes tests, CI runners, and coverage-risk signals.

Summary

Area Added Changed Deleted
Test files 0 3 0
E2E/journey files 0 1 0
Workflow files 0 0 0

Signals

  • Test cases: +2 / -1
  • Assertions: +10 / -3
  • Skips or known failures added: 0
  • Workflow continue-on-error added: 0
  • Workflow path filters added: 0
  • Test commands removed from justfile: 0
  • E2E/journey retry lines added: 0

Coverage risk: needs review

Warnings

  • E2E or journey files changed (needs review)
    • tests/e2e-mw-dev/harness.sh

@benben benben merged commit e1464b8 into main Jul 3, 2026
28 checks passed
@benben benben deleted the ben/default-team-id-mandatory branch July 3, 2026 13:53
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