fix(identity): accept Entra's space-delimited scp string claim (Copilot SystemError) - #244
Merged
Conversation
Microsoft Entra packs the delegated-scope claim `scp` as a
space-delimited STRING (`"access_as_user User.Read"`), but the verifier
deserialized `scp` only as a JSON array. Every Entra delegated token
therefore failed verification with
JWT verification failed: JSON error: invalid type: string
"access_as_user", expected a sequence
i.e. a bare 401 — which Copilot Studio surfaced to the operator as an
opaque `SystemError` with nothing actionable. Confirmed live 2026-08-30:
`POST /a2a` from CopilotStudio PowerFx reached the pod and was rejected
with exactly this error_detail.
`scp` now deserializes from either a string (whitespace-split, the OAuth2
`scope` convention Entra follows) or an array. `scopes()` is unchanged.
Test: scp string form, array form, scope-only fallback, and absent all
deserialize and yield the right scopes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
The actual Copilot Studio SystemError
With the card-path fix (#243) deployed, Copilot Studio's runtime finally reaches the agent:
POST /a2afromCopilotStudio PowerFx/1.99.0hit the pod (2026-08-30). It was rejected 401 with:Microsoft Entra packs the delegated-scope claim
scpas a space-delimited string ("access_as_user User.Read"). The verifier deserializedscponly as a JSON array, so every Entra delegated token failed at deserialization — before any scope/audience logic — as a bare 401. Copilot surfaces that as an opaqueSystemErrorwith no detail, which is why it looked Microsoft-side.Fix
scpnow deserializes from either a string (whitespace-split, exactly the OAuth2scopeconvention Entra follows) or an array.scopes()is unchanged; Google tokens (array/scope) are unaffected.Test
scp_claim_accepts_both_entra_string_and_array_forms: string form, array form,scope-only fallback, and absent-all each deserialize and yield the right scopes.cargo test -p triton-identity→ 6 passed; clippy clean.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.