Skip to content

Let PrincipalResolverError carry a stable error code, not only a status #1623

Description

@bokelley

Ask

Let PrincipalResolverError carry a stable, machine-readable error code alongside the status. A code drawn from a constrained set (for example ^[a-z][a-z0-9_]{0,63}$) adds no risk of leaking exception text.

Why

#1328's non-bearer principal resolver is the right replacement for adopter auth bridges, but its rejection is fixed: PrincipalResolverError(403) always answers 403 {"error": "forbidden"}. That is safe by design (no exception text reaches the caller), but sellers with documented rejection codes can't express them.

The Embedded Sales Agent's embedded mode returns documented 403 bodies such as identity_required, identity_org_mismatch and network_policy_denied, which its integrator branches on. That's why ESA can't move its embedded_buyer_auth_bridge onto the resolver.

Suggested shape

raise PrincipalResolverError(403, code="identity_org_mismatch")
# -> 403 {"error": "identity_org_mismatch"}

Validate code against the pattern, fall back to the generic body if it doesn't match, and never include the exception message.

Activity

  1. added 2 commits that reference this issue on Oct 26, 2026
    5deec1c
    cf96d57
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions