Require default_team_id when provisioning a new org#890
Merged
Conversation
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.
Test Impact PlanDeterministic summary of how this PR changes tests, CI runners, and coverage-risk signals. Summary
Signals
Coverage risk: needs review Warnings
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Pull-based compute billing keys usage buckets by
team_id(the org's default team). Thedefault_team_idcolumn 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
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.PUT /orgs/:idset/clear behavior is unchanged (operator escape hatch).Tests
TestProvisionNewOrgRequiresDefaultTeamID(400 + nothing created, error names the field),TestReprovisionExistingOrgKeepsDefaultTeamID(existing org keeps value on omission); fake store mirrors the real transaction semantics.harness.sh):default_team_id_optional→default_team_id_mandatory— both ducklings provision WITH a team id and round-trip it viaGET /orgs/:id, a brand-new org WITHOUT one is rejected with 400 naming the field andGET /orgs/:idstays 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) carrydefault_team_id.🤖 Generated with Claude Code