-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Bug Category
Cedar Policy Editing
Describe the bug
Formatting and validation crash in the Cedar VS Code extension when an annotation string contains the standalone word Action. The extension throws a TypeError and the formatting provider fails.
From the stack trace, the crash occurs while parsing policy text and trying to read length from an undefined value. This appears to happen when Action in annotation text is interpreted as an action type token without an action id.
Expected behavior
Formatting and validation should succeed regardless of annotation label text. Annotation strings should not be parsed as policy entity/action references.
Reproduction steps
- Open a Cedar policy file in VS Code.
- Add a policy annotation containing standalone Action text, for example:
- @id("Example Action Policy")
- Include a normal policy body under it.
- Run Format Document (or trigger validation).
- See extension error and failed formatting provider.
Code Snippet
@id("Example Action Policy")
permit (
principal is App::User,
action == App::Action::"example",
resource is App::Sample
);
A workaround that avoids the crash:
@id("Example Alternative Policy")
Log output
2026-03-18 13:05:38.308 [error] [cedar-policy.vscode-cedar] provider FAILED
2026-03-18 13:05:38.309 [error] TypeError: Cannot read properties of undefined (reading 'length')
at .../out/parser.js:170:68
at Array.forEach (<anonymous>)
at parseCedarPoliciesDoc (.../out/parser.js:162:20)
at validateCedarDoc (.../out/validate.js:202:52)
at Object.provideDocumentFormattingEdits (.../out/extension.js:261:19)
2026-03-18 13:05:39.330 [error] TypeError: Cannot read properties of undefined (reading 'length')
at .../out/parser.js:170:68
at Array.forEach (<anonymous>)
at parseCedarPoliciesDoc (.../out/parser.js:162:20)
at validateCedarDoc (.../out/validate.js:202:52)
Additional configuration
No response
Visual Studio Code version
Version: 1.111.0 Commit: ce099c1ed25d9eb3076c11e4a280f3eb52b4fbeb
Cedar policy language extension version
0.10.2
Additional information and screenshots
Likely root cause: parser token matching is not ignoring annotation string literals, and standalone Action text is treated like an action type reference without an id.
Suggested fix: guard against missing id before reading length, and/or skip scanning annotation string literals for entity/action references.