Git Product home page Git Product logo

Comments (2)

samscott89 avatar samscott89 commented on May 31, 2024

Hey @IohannesArnold. Apologies for the slow response here, and for the issues you've encountered.

Is this a bug in oso or my failure to write a proper ruleset? If the latter, I think that the documentation could be clearer

It's kind of a bit of both.

It's currently a pretty big limitation/sharp edge of Polar that we'd like to remove. You're right that Polar is looking for an existential assertion, and currently the problem is the rule:

has_relation(parent: Group, "managing_group", child: Group) if
    child.managed_by.id = parent.id;

Which creates a partially-constrained variable parent which has the properties parent matches Group and parent.id = 2.

Which then goes through to the has_role rule and ends up adding more conditions, which it can't handle.

To address it, you would need to write the rule as:

has_relation(parent: Group, "managing_group", child: Group) if
    child.managed_by = parent;

which should work fine.

We'd like to improve this in future versions

from oso.

WaldoJeffers avatar WaldoJeffers commented on May 31, 2024

I'm running into the same issue, and the above solution by @samscott89 only works if both child.managed_by and parent are strictly identical. It's my understanding that at the moment, the Polar compares every property between the two dictionaries.

However, if one of the two dictionaries has a single property with a different value (let's say a metadata field with a timestamp, or anything else outside of the primary key), the two dictionaries won't be considered equal, and the assertion will fail.

This behaviour seems a bit limiting, considering there are many cases where you might have slightly different dictionaries (maybe one of them is a partial copy of the other, maybe it's been slightly altered before an update operation). Also, in most cases, you might not have a managed_by dictionary property but rather a string one, like manager_id, which you would want to compare to parent.id. Does that mean this use case is not supported?

Isn't there a more foolproof way of explaining to Polar how it's supposed to consider that two dictionaries are equal?

from oso.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.