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

any_prefix_match differs from doc #5126

Closed
ericjkao opened this issue Sep 12, 2022 · 3 comments
Closed

any_prefix_match differs from doc #5126

ericjkao opened this issue Sep 12, 2022 · 3 comments
Labels

Comments

@ericjkao
Copy link
Contributor

Short description

In OPA 0.44.0, the new strings.any_prefix_match behaves differently from docs.
Docs say:

Returns true if any of the search strings begins with any of the base strings.

But in fact, strings.any_prefix_match({"x-0, z-0"}, "z-") evaluates to false contrary to the doc.

Steps To Reproduce

https://play.openpolicyagent.org/p/G5VMwfeI6s
See lines 11 and 14.

Expected behavior

According to doc and the motivating example in issue, both lines should evaluate to true.

Additional context

Strange that this bug exists and does not fail this test case:

strings: ["a/b/c", "a/b/d", "e/f/g"]

Hmmm.

@ericjkao ericjkao added the bug label Sep 12, 2022
@srenatus
Copy link
Contributor

{"x-0, z-0"}

☝️ This is a set containing of one string: "x-0, z-0". Did you mean to use

{"x-0", "z-0"}

a set of two strings, by any chance? 🤔

@srenatus
Copy link
Contributor

BTW we really need more examples in the docs, #4623

@ericjkao
Copy link
Contributor Author

Oh lol that's a hilarious mistake on my part!

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