Skip to content

inspect omits location information in annotations since version 1.1.0 #7459

@mostealth

Description

@mostealth

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions