You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Bug Category
Other
Describe the bug
Given a file containing the following policy (taken from the Cedar docs), with a trailing newline:
// Jane's friends can view all photos in her janeTrips album
permit (
principal in Group::"janeFriends",
action in [Action::"view", Action::"comment"],
resource in Album::"janeTrips"
);
The cedar format --check command exits with a non-0 status:
$ cedar format --policies ./test.cedar --line-width 80 --indent-width 2 --check --error-format human
// Jane's friends can view all photos in her janeTrips album
permit (
principal in Group::"janeFriends",
action in [Action::"view", Action::"comment"],
resource in Album::"janeTrips"
);
adam.rothman at adamrot-ltmnvzm in ~/Desktop
$ echo $?
1
Expected behavior
The format command should not treat a policy file that ends with a newline as malformed or in need of formatting. It's very common for editors to automatically add a trailing newline to files on save, and quite a pain to try to disable this feature for only .cedar files.
When invoked with --check, policy files that end with a trailing newline should pass (i.e. exit status 0).
When invoked with --write, the CLI should not remove trailing newlines from policy files where they are present.
Reproduction steps
Install cedar-policy-cli crate.
Save the example policy above into a file called test.cedar, ensuring that a trailing newline is added.
Invoke cedar format --check.
Check the exit code of the previous command.
$ cargo install cedar-policy-cli
Updating crates.io index
Downloaded cedar-policy-cli v4.0.0
Downloaded 1 crate (43.5 KB) in 0.22s
Installing cedar-policy-cli v4.0.0
<snip>
Compiling cedar-policy-cli v4.0.0
Finished `release` profile [optimized] target(s) in 34.42s
Installing /Users/adam.rothman/.cargo/bin/cedar
Installed package `cedar-policy-cli v4.0.0` (executable `cedar`)
$ cedar -V
cedar-policy-cli 4.0.0
$ cat test.cedar
// Jane's friends can view all photos in her janeTrips album
permit (
principal in Group::"janeFriends",
action in [Action::"view", Action::"comment"],
resource in Album::"janeTrips"
);
$ cat -e test.cedar
// Jane's friends can view all photos in her janeTrips album$
permit ($
principal in Group::"janeFriends",$
action in [Action::"view", Action::"comment"],$
resource in Album::"janeTrips"$
);$
$ cedar format --policies ./test.cedar --line-width 80 --indent-width 2 --check --error-format human
// Jane's friends can view all photos in her janeTrips album
permit (
principal in Group::"janeFriends",
action in [Action::"view", Action::"comment"],
resource in Album::"janeTrips"
);
$ echo $?
1
Code Snippet
No response
Log output
No response
Additional configuration
No response
Operating System
macOS Sonoma 14.7
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered:
adamrothman
added
bug
Something isn't working. This is as high priority issue.
pending-triage
The cedar maintainers haven't looked at this yet. Automicaly added to all new issues.
labels
Sep 19, 2024
Thanks for opening this issue! That behavior does indeed sound annoying. Should be a quick fix -- I'll take a look now.
khieta
added
work-in-progress
papercut
Small annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a fature request
and removed
bug
Something isn't working. This is as high priority issue.
pending-triage
The cedar maintainers haven't looked at this yet. Automicaly added to all new issues.
labels
Sep 20, 2024
Fixed by #1220. This change will naturally be included in the next minor version (4.1.0). But let us know if you need it asap and we can release a patch version 4.0.1.
Before opening, please confirm:
Bug Category
Other
Describe the bug
Given a file containing the following policy (taken from the Cedar docs), with a trailing newline:
The
cedar format --check
command exits with a non-0 status:Expected behavior
The
format
command should not treat a policy file that ends with a newline as malformed or in need of formatting. It's very common for editors to automatically add a trailing newline to files on save, and quite a pain to try to disable this feature for only.cedar
files.When invoked with
--check
, policy files that end with a trailing newline should pass (i.e. exit status 0).When invoked with
--write
, the CLI should not remove trailing newlines from policy files where they are present.Reproduction steps
cedar-policy-cli
crate.test.cedar
, ensuring that a trailing newline is added.cedar format --check
.Code Snippet
No response
Log output
No response
Additional configuration
No response
Operating System
macOS Sonoma 14.7
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: