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 annotations behavior is different than the spec #6742

Open
msorens opened this issue May 8, 2024 · 3 comments
Open

Metadata annotations behavior is different than the spec #6742

msorens opened this issue May 8, 2024 · 3 comments

Comments

@msorens
Copy link
Contributor

msorens commented May 8, 2024

Short description

With opa 0.64.1, the metadata is not being processed per the spec; so either opa is wrong or the spec is wrong on this.
Regarding metadata annotations the spec says:

...every line in the comment block containing the annotation must start at Column 1 in the module/file, or otherwise, they will be ignored

Steps To Reproduce

Consider this rego file (note the description line comment does NOT start in column 1):

package test
import rego.v1

# METADATA
# title: rule
 # description: description
# custom: 
#  rule_types: [deny, allow]
allow if {
  true
}

Run opa inspect -a . on that directory.

Expected behavior

It should recognize both the title and custom properties.

Actual behavior

opa recognizes only the title property.

Additional context

It is acting as though the “comment block” should stop at the first line that is not in column 1. That is incorrect because the spec goes on to say that there is only one way to end a comment block:

...include a blank line immediately after the comment block containing the YAML document. This tells OPA that the comment block containing the YAML document is finished

@msorens msorens added the bug label May 8, 2024
@ashutosh-narkar
Copy link
Member

@johanfylling is this expected behavior that needs a doc update or a bug?

@johanfylling
Copy link
Contributor

johanfylling commented May 10, 2024

I believe this is a matter of the documentation needing further clarification.

If a user wants to have comments inside the METADATA yaml, they can inline yaml-style comments, e.g.:

# METADATA
# title: foo
# # This is a comment
# description: bar

This might need explicit documentation too 🤔 .

@ashutosh-narkar
Copy link
Member

Yeah would be good to document the expected behavior here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants