foundry_dev_tools.utils.scope module#

Helpers for explaining the scope of the current Foundry token.

foundry_dev_tools.utils.scope.COMPASS_RID_PREFIX = 'ri.compass.'#

Only Compass resources are reported; other resource types are ignored.

foundry_dev_tools.utils.scope.COMPASS_NOT_FOUND_ERROR_NAME = 'Compass:NotFound'#

Foundry reports resources outside a token’s scope as not found instead of forbidden.

foundry_dev_tools.utils.scope.SCOPE_DIAGNOSTICS_TIMEOUT = (5, 10)#

Connection/read timeout for the scope request so it cannot delay the original error.

foundry_dev_tools.utils.scope.parse_compass_resources(payload)[source]#

Return the Compass resources referenced by a /multipass/api/me/scope response.

Parameters:

payload (object)

Return type:

tuple[str, …]

foundry_dev_tools.utils.scope.describe_compass_resources(context)[source]#

Return the Compass resources referenced by the token scope, if it can be read.

Parameters:

context (FoundryContext)

Return type:

tuple[str, …] | None

foundry_dev_tools.utils.scope.build_auth_error_hint(context, status_code, error_name=None)[source]#

Build a user-facing hint for authentication and permission responses.

An expiry note is added for any token provider that knows when its current token expires. Providers that opt in via supports_scope_diagnostics additionally get the Compass resources referenced by their token scope for 403 responses and 404 Compass responses, which Foundry uses to mask resources outside the token’s scope. The original exception is never replaced; callers append the returned text to it.

Parameters:
Return type:

str | None