Skip to content

Nicer errors on "evaluate" with syntax errors in context/entities - #17

Merged
john-h-kastner-aws merged 3 commits into
mainfrom
playground-entities-context-error
Jul 9, 2026
Merged

john-h-kastner-aws merged 3 commits into
mainfrom
playground-entities-context-error

Conversation

@john-h-kastner-aws

@john-h-kastner-aws john-h-kastner-aws commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The fall-through to WASM errors didn't given useful error messages. By treating an invalid context as empty we would get some unrelated validation error complaining about missing attributes, or it could even proceed to authorization if the action accepted an empty context.

For invalid JSON in the context:

old:

image

new:

image

Signed-off-by: John Kastner <jkastner@amazon.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the Policy Playground “Evaluate” flow by surfacing a clear UI error when context or entities contain invalid JSON (instead of deferring to WASM error output), and adds regression tests covering both invalid-input cases.

Changes:

  • Add explicit JSON parsing with early-return error output for entities and context in evaluateInput.
  • Add sandbox tests that load invalid entities/context via URL hash and assert the improved error message is shown.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/routes/policy-playground/PolicyPlayground.tsx Adds explicit JSON parse error handling for entities and context before invoking isAuthorized.
tests/sandbox.test.tsx Adds tests that verify the UI displays the “Invalid context or entities input” message for invalid JSON in entities and context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/sandbox.test.tsx
Comment thread tests/sandbox.test.tsx
Signed-off-by: John Kastner <jkastner@amazon.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/routes/policy-playground/PolicyPlayground.tsx
Comment thread tests/sandbox.test.tsx
Comment thread tests/sandbox.test.tsx
Signed-off-by: John Kastner <jkastner@amazon.com>
@john-h-kastner-aws
john-h-kastner-aws merged commit 6deceff into main Jul 9, 2026
4 checks passed
@john-h-kastner-aws
john-h-kastner-aws deleted the playground-entities-context-error branch July 9, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants