Skip to content

fix: OPA policy approval gates fail open on unrecognized decision payloads - #19981

Open
ai-sdk-factory[bot] wants to merge 3 commits into
mainfrom
bugfix-19978-20260829054255010235
Open

fix: OPA policy approval gates fail open on unrecognized decision payloads#19981
ai-sdk-factory[bot] wants to merge 3 commits into
mainfrom
bugfix-19978-20260829054255010235

Conversation

@ai-sdk-factory

Copy link
Copy Markdown
Contributor

Background

Unrecognized OPA policy payloads normalized to no opinion, allowing protected tools to execute without approval and creating a fail-open policy gate.

Root Cause

normalizeOpaDecision mapped every unsupported non-null result to not-applicable, which generateText treats as direct execution. The reproduction confirmed four malformed decision shapes executed the protected tool.

Summary

Changed OPA decision normalization to deny unrecognized non-null results with a clear reason while preserving nullish and explicit not-applicable behavior. Updated documentation and added a patch changeset.

Testing

Added normalization coverage for malformed decision variants and an end-to-end generateText regression test confirming unrecognized decisions produce execution-denied results.

End-to-end Validation

  • Immutable replay of pnpm -C examples/ai-functions exec tsx src/reproduction/policy-opa-unrecognized-decision-fail-open.ts exited successfully; all four malformed decisions were denied and the protected tool did not execute.

Related Issues

Fixes #19978

Closes #19980

ai-sdk-factory and others added 3 commits August 29, 2026 05:48
Co-authored-by: AUTHENSOR <250658088+AUTHENSOR@users.noreply.github.com>
Co-authored-by: AUTHENSOR <250658088+AUTHENSOR@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/policy-opa treats unrecognized policy decisions as "no opinion" and the tool gate fails open

1 participant