Skip to content

inspect omits location information in annotations since version 1.1.0 #7459

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

Open
mostealth opened this issue Mar 21, 2025 · 1 comment
Open
Labels

Comments

@mostealth
Copy link

Short description

Since version opa 1.1.0, I think after #7281, location information in annotations is missing.

Steps To Reproduce

mymodule.rego

package terraform

# METADATA
# description: My description
# authors:
# - "myself"

error_my_rule contains msg if {
	msg = `firing`
}

opa v1.0.1
$ opa inspect -a ./mymodule.rego --format=json

{
  "signatures_config": {},
  "namespaces": {
    "data.terraform": [
      "mymodule.rego"
    ]
  },
  "annotations": [
    {
      "annotations": {
        "authors": [
          {
            "name": "myself"
          }
        ],
        "description": "My description",
        "scope": "rule"
      },
      "location": {
        "file": "./mymodule.rego",
        "row": 8,
        "col": 1
      },
      "path": [
        {
          "type": "var",
          "value": "data"
        },
        {
          "type": "string",
          "value": "terraform"
        },
        {
          "type": "string",
          "value": "error_my_rule"
        }
      ]
    }
  ],
  "capabilities": {
    "builtins": [
      {
        "name": "eq",
        "decl": {
          "args": [
            {
              "type": "any"
            },
            {
              "type": "any"
            }
          ],
          "result": {
            "type": "boolean"
          },
          "type": "function"
        },
        "infix": "="
      }
    ],
    "features": [
      "rego_v1"
    ]
  }
}

opa v1.1.0
$ opa inspect -a ./mymodule.rego --format=json

{
  "signatures_config": {},
  "namespaces": {
    "data.terraform": [
      "mymodule.rego"
    ]
  },
  "annotations": [
    {
      "annotations": {
        "authors": [
          {
            "name": "myself"
          }
        ],
        "description": "My description",
        "scope": "rule"
      },
      "path": [
        {
          "type": "var",
          "value": "data"
        },
        {
          "type": "string",
          "value": "terraform"
        },
        {
          "type": "string",
          "value": "error_my_rule"
        }
      ]
    }
  ],
  "capabilities": {
    "builtins": [
      {
        "name": "eq",
        "decl": {
          "args": [
            {
              "type": "any"
            },
            {
              "type": "any"
            }
          ],
          "result": {
            "type": "boolean"
          },
          "type": "function"
        },
        "infix": "="
      }
    ],
    "features": [
      "rego_v1"
    ]
  }
}

Expected behavior

Expect to see location information

Additional context

@mostealth mostealth added the bug label Mar 21, 2025
@anderseknert
Copy link
Member

Thanks for reporting this! Yeah, that's likely a case our tests didn't cover 😅

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

No branches or pull requests

2 participants