Files
floci/docs
Sam Fakhreddine 18521edf28 feat(organizations): add ListAccountsWithInvalidEffectivePolicy (#2628)
* feat(organizations): add ListAccountsWithInvalidEffectivePolicy

Effective-policy validation is not modeled, so the operation returns an
explicit empty Accounts list rather than fabricating data. Documented as
a limitation in docs/services/organizations.md.

* fix(organizations): validate PolicyType on ListAccountsWithInvalidEffectivePolicy

The operation takes a required PolicyType drawn from the EffectivePolicyType
enum, and the handler ignored it entirely: any string — NOT_A_POLICY,
SERVICE_CONTROL_POLICY — was answered 200 with an empty Accounts list, which
reads as "no account has an invalid effective policy" when AWS would have
rejected the request outright.

Route the operation through the service so it validates PolicyType the way
DescribeEffectivePolicy does, and lift that check into a shared helper.

EFFECTIVE_POLICY_TYPES is floci's rendering of the EffectivePolicyType shape
and had drifted five values behind the model (INSPECTOR_POLICY,
UPGRADE_ROLLOUT_POLICY, BEDROCK_POLICY, S3_POLICY,
NETWORK_SECURITY_DIRECTOR_POLICY); widened so the new validation enforces the
enum rather than a subset of it.

* fix(organizations): restrict ListAccountsWithInvalidEffectivePolicy to management/delegated admin

An ordinary member account could call this operation and get HTTP 200 with an
empty Accounts list, indistinguishable from "everything checked out fine".
The botocore model restricts it to the management account or a member account
registered as a delegated administrator - unlike DescribeEffectivePolicy, which
any account in the organization may call.

Add requireManagementOrDelegatedAdmin alongside the existing
requireOrganizationForCaller/requireManagementAccount pair and route this
operation through it.

* fix(organizations): tighten ListAccountsWithInvalidEffectivePolicy to management-only

requireManagementOrDelegatedAdmin (added in the prior commit) let a member
delegated as admin for any unrelated service - config.amazonaws.com in the
new test - through, since it only checked whether the account's
delegatedServices map was non-empty rather than which service.

The model names no service this operation's delegation should be scoped to,
and EffectivePolicyType maps to none, so there is nothing to check a
registration against. Collapse to requireManagementAccount instead, matching
every other operation gated on this same boilerplate phrase in this file
(attachPolicy, enablePolicyType, registerDelegatedAdministrator,
listDelegatedAdministrators) - stricter than the model text, consistently so.

Removes the now-unused requireManagementOrDelegatedAdmin helper.

* fix(organizations): echo PolicyType on ListAccountsWithInvalidEffectivePolicy

Accounts is always empty by design here, so PolicyType was the only field the
response could carry any information in, and it was being dropped by the
shared accountsResponse() helper (built for the two-member ListAccounts shape).
Builds the response inline instead, echoing the validated PolicyType back per
the modeled response shape. Also closes a stray blank line above
requireManagementAccount's javadoc, and expands the delegated-administrator
note on why management-only is correct today.
2026-08-27 15:21:10 -04:00
..
2026-03-15 17:43:56 -05:00