Skip to content

Organizations: ListRoots mints a new random root ID on every call, so the root has no identity #577

Closed

Description

@scttfrdmn

emulator/organizations_plugin.go:261:

rootID := "r-" + randomLowerHex(4)
root := OrgRoot{ID: rootID, ...}

The root ID is generated per request and never persisted, so two ListRoots calls against the same account return two different roots. Nothing else in the plugin references a root today, which is why this is invisible — but the root ID is the target every Organizations control attaches to, so it becomes load-bearing the moment AttachPolicy, EnablePolicyType, CreateOrganizationalUnit, or ListParents exist (see #578).

An organization has exactly one root for its lifetime. The failure mode for a caller is not an error: it reads the root, attaches a policy to it, reads the root again to verify, gets a different ID, and concludes the attachment is missing. Or it walks ListParents upward looking for a terminating root ID it can never match.

Expected

ListRoots returns the same root for the lifetime of the organization. Since ensureOrganization already auto-creates on first touch and persists under org:<acct>, the natural fix is to create the root there and store it alongside — one root per organization, generated once.

Related

FeatureSet is hardcoded "ALL" at organizations_plugin.go:89. That is the right default, but it should be settable: an organization in CONSOLIDATED_BILLING mode cannot hold a service control policy at all, and a tool that has to refuse that state has no way to reach it. Likewise PolicyTypes is hardcoded to SERVICE_CONTROL_POLICY: ENABLED at :265 — the disabled case is the interesting one, because in a real organization CreatePolicy and AttachPolicy both succeed while the policy type is off and nothing is enforced. See the fixture-seeding request in the Organizations operations issue.

Repro

srv := emulator.StartTestServer(t)
a, _ := orgs.ListRoots(ctx, &organizations.ListRootsInput{})
b, _ := orgs.ListRoots(ctx, &organizations.ListRootsInput{})
// *a.Roots[0].Id != *b.Roots[0].Id

Activity

  1. added
    type: bug
    priority: high
    on Aug 5, 2026
  2. added this to the v0.97.0 milestone on Aug 9, 2026
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

    area: organizationspriority: hightype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions