Skip to content

store: Improve conflicting root error message#7808

Merged
charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom
charlieegan3:conflict
Jul 31, 2025
Merged

store: Improve conflicting root error message#7808
charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom
charlieegan3:conflict

Conversation

@charlieegan3
Copy link
Copy Markdown
Contributor

Fixes #7806

$ opa eval -b b1.tar.gz -b b2.tar.gz data;  go run main.go eval -b b1.tar.gz -b b2.tar.gz data
{
  "errors": [
    {
      "message": "detected overlapping roots in bundle manifest with: [b1.tar.gz b2.tar.gz]"
    }
  ]
}
{
  "errors": [
    {
      "message": "bundles b2.tar.gz, b1.tar.gz have overlapping roots and cannot be activated simultaneously because bundles b1.tar.gz specify empty root paths ('') which overlap with any other bundle root"
    }
  ]
}

@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 31, 2025

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit a85d8f1
🔍 Latest deploy log https://app.netlify.com/projects/openpolicyagent/deploys/688b4dd69144dd000899aa16
😎 Deploy Preview https://deploy-preview-7808--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread v1/bundle/store.go Outdated
return fmt.Errorf("detected overlapping roots in bundle manifest with: %s", bundleNames)

if len(bundlesWithEmptyRoots) > 0 {
return fmt.Errorf("bundles %s have overlapping roots and cannot be activated simultaneously because bundles %s specify empty root paths ('') which overlap with any other bundle root", strings.Join(bundleNames, ", "), strings.Join(bundlesWithEmptyRoots, ", "))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"...bundles %s specify..." 🤔 OK this is 100% pedantry, but let's do a compromise:

Suggested change
return fmt.Errorf("bundles %s have overlapping roots and cannot be activated simultaneously because bundles %s specify empty root paths ('') which overlap with any other bundle root", strings.Join(bundleNames, ", "), strings.Join(bundlesWithEmptyRoots, ", "))
return fmt.Errorf("bundles %s have overlapping roots and cannot be activated simultaneously because bundle(s) %s specify empty root paths ('') which overlap with any other bundle root", strings.Join(bundleNames, ", "), strings.Join(bundlesWithEmptyRoots, ", "))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had the same thought, I am making some minor updates to the messages!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, Changed it to:

{
  "errors": [
    {
      "message": "detected overlapping roots in bundle manifest with: [b2.tar.gz b1.tar.gz]"
    }
  ]
}
{
  "errors": [
    {
      "message": "bundles [b1.tar.gz, b2.tar.gz] have overlapping roots and cannot be activated simultaneously because bundle(s) [b1.tar.gz] specify empty root paths ('') which overlap with any other bundle root"
    }
  ]
}

Along with some other edits.

Comment thread v1/bundle/store_test.go Outdated
expectedError: "detected overlapping roots manifests for these bundles: [bundle1, bundle2, bundle3]",
},
{
note: "overlap with empty root bundle - bundle without manifest",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me see if I can get this to show the longer message too.

@charlieegan3 charlieegan3 force-pushed the conflict branch 7 times, most recently from f0b1520 to 5ae49ca Compare July 31, 2025 10:51
Copy link
Copy Markdown
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

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

Thanks!

@charlieegan3
Copy link
Copy Markdown
Contributor Author

Thanks Stephan! added some fixes to the tests in https://github.com/open-policy-agent/opa/pull/7808/files#diff-2923c292692c11e167d80502ff31fb2c991c92cec3ae3686e1acf756fc02e7d4, but will merge when all passing

Fixes open-policy-agent#7806

```
{
  "errors": [
    {
      "message": "detected overlapping roots in bundle manifest with: [b2.tar.gz b1.tar.gz]"
    }
  ]
}
{
  "errors": [
    {
      "message": "bundles [b1.tar.gz, b2.tar.gz] have overlapping roots and cannot be activated simultaneously because bundle(s) [b1.tar.gz] specify empty root paths ('') which overlap with any other bundle root"
    }
  ]
}
```

Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 merged commit d0132ee into open-policy-agent:main Jul 31, 2025
31 checks passed
@charlieegan3 charlieegan3 deleted the conflict branch July 31, 2025 11:16
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.

build: Improve multi bundle loading and building error messages based on .manifest presence

2 participants