Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata block in Rego comment can not contain non-breaking space #4475

Closed
johanfylling opened this issue Mar 24, 2022 · 4 comments · Fixed by #5567
Closed

Metadata block in Rego comment can not contain non-breaking space #4475

johanfylling opened this issue Mar 24, 2022 · 4 comments · Fixed by #5567
Assignees
Labels

Comments

@johanfylling
Copy link
Contributor

johanfylling commented Mar 24, 2022

If the following policy contains non-breaking spaces (\u00A0)

# METADATA
# description: Optional authorization policy to use for protecting the OPA REST API if exposed on a public endpoint.
package system.authz

compilation will fail with

error: bundle .: 1 error occurred: authz.rego:1: rego_parse_error: yaml: unmarshal errors:
  line 1: cannot unmarshal !!str `descrip...` into ast.rawAnnotation
	# METADATA
@johanfylling
Copy link
Contributor Author

I have not been able to replicate this, but @anderseknert encountered this when running opa inspect -a.

@anderseknert
Copy link
Member

# METADATA
# description: foo is not bar
package main

@johanfylling sorry, I think it's Shift + Opt + Space to create these. Not sure if GitHub is kind enough to "fix" that in the above, but if so let me know and I'll send you the file.

@anderseknert
Copy link
Member

I think it's fine to fail here, but the error message could certainly be improved!

@stale
Copy link

stale bot commented Apr 24, 2022

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.

@stale stale bot added the inactive label Apr 24, 2022
@stale stale bot removed the inactive label Jan 11, 2023
johanfylling added a commit to johanfylling/opa that referenced this issue Jan 18, 2023
* Properly divine Rego location for yaml unmarshal errors
* Error hint for cases where non-legal space is used with yaml key/value separator `:`

Fixes: open-policy-agent#4475
Signed-off-by: Johan Fylling <[email protected]>
johanfylling added a commit to johanfylling/opa that referenced this issue Jan 18, 2023
* Properly divine Rego location for yaml unmarshal errors
* Error hint for cases where non-legal space is used with yaml key/value separator `:`

Fixes: open-policy-agent#4475
Signed-off-by: Johan Fylling <[email protected]>
ashutosh-narkar pushed a commit to johanfylling/opa that referenced this issue Jan 19, 2023
* Properly divine Rego location for yaml unmarshal errors
* Error hint for cases where non-legal space is used with yaml key/value separator `:`

Fixes: open-policy-agent#4475
Signed-off-by: Johan Fylling <[email protected]>
johanfylling added a commit that referenced this issue Jan 19, 2023
…5567)

* ast: Improving error information when metadata yaml fails to compile

* Properly divine Rego location for yaml unmarshal errors
* Error hint for cases where non-legal space is used with yaml key/value separator `:`

Fixes: #4475
Signed-off-by: Johan Fylling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants