Skip to content

Remove go-semver dependency, plus various fixes#1746

Merged
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:pre-release-fixes
Nov 4, 2025
Merged

Remove go-semver dependency, plus various fixes#1746
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
anderseknert:pre-release-fixes

Conversation

@anderseknert
Copy link
Member

  • Use a single eval to get both enabled regular and aggregate rules
  • Prefer to use once-initialized io.Capabilities over ast.CapabilitiesForThisVersion
  • Add rego.BuiltinsForDefaultCapabilities for the language server
  • Some light refactoring, mainly to have code use existing util methods

@@ -0,0 +1,213 @@
package semver_test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these tests were copied from the coreos list, perhaps we should reference that here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll add a note. Thanks!

Copy link
Contributor

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me!

@anderseknert
Copy link
Member Author

Well this is certainly intriguing. CI fails because one particular test now exceeds the default 5 seconds timeout threshold! While the test obviously runs faster locally, the issue is easily seen here too, clocking in at almost a second!

  {
    "location": {
      "file": "bundle/regal/main/main_test.rego",
      "row": 285,
      "col": 1
    },
    "package": "data.regal.main_test",
    "name": "test_lint_from_stdin_disables_rules_depending_on_filename_creates_notices",
    "duration": 946422292,
  }

Now trying to understand what in this change possibly could cause this. The regal lint bundle benchmark doesn't show any equivalent regression, making this even more of a mystery. Will report back later on what I find.

@anderseknert
Copy link
Member Author

anderseknert commented Nov 3, 2025

(Also, making a note for us to change that threshold to 1 second once this is fixed. Even in CI, I don't think we'll ever have individual tests take that long unless there's an issue somewhere... and we'd want to know that sooner rather than later)

@anderseknert
Copy link
Member Author

Looks like this is caused the rules that were previously external queries but moved into policy with this PR:

# METADATA
# description: enabled regular rules (LSP usecase only)
enabled.rules.regular contains rule if {
	some cat, rule
	data.regal.rules[cat][rule]
	object.get(data.regal.rules[cat][rule], "notices", set()) == set()
	not config.ignored_rule(cat, rule)
	not rule in enabled.rules.aggregate
}

# METADATA
# description: enabled aggregate rules (LSP usecase only)
enabled.rules.aggregate contains rule if {
	some cat, rule
	data.regal.rules[cat][rule].aggregate
	not config.ignored_rule(cat, rule)
}

I did not look closely at what these do, but they clearly trigger a full evaluation of all rules 😅 Which previously would happen only when the language server started or config got reloaded. Why this particular test triggers this is beyond me... but perhaps it's just where it's reported? 🤔 I will revert this change for now, but we will need to prioritize having this fixed in the language server too, as this blocks the initialize method, causing a long delay until the client gets to a working state.

- Use a single eval to get both enabled regular and aggregate rules
- Prefer to use once-initialize `io.Capabilities` over `ast.CapabilitiesForThisVersion`
- Add `rego.BuiltinsForDefaultCapabilities` for the language server
- Some light refactoring, mainly to have code use existing util methods
- Set timeouts for tests to 1s rather than default 5s

Signed-off-by: Anders Eknert <anders@eknert.com>
@anderseknert
Copy link
Member Author

I went ahead and fixed the above issue instead, Now it performs really well, but sadly using a little less Rego. Fixing that will be for a future change :)

@anderseknert anderseknert merged commit 4384b0d into open-policy-agent:main Nov 4, 2025
8 checks passed
@anderseknert anderseknert deleted the pre-release-fixes branch November 4, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants