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

Allow dots in dict_path predicate #8878

Open
cukiernick opened this issue Mar 28, 2025 · 1 comment
Open

Allow dots in dict_path predicate #8878

cukiernick opened this issue Mar 28, 2025 · 1 comment

Comments

@cukiernick
Copy link

I'd like to identify list element based on a key with dots in the string.

def test_dict_path():
    d = dict(
        neighbors = [
            dict(ip="1.1.1.1", prefix="a"),
            dict(ip="2.2.2.2", prefix="b"),
        ],
        foo="bar",
    )

    path = to_path("neighbors[ip=2.2.2.2].prefix")
    assert path.get_element(d) == "b"

raised error:

inp = 'neighbors[ip=2'

    def parse_element(inp: str) -> WildDictPath:
        for subtype in cls.element_types:
            parsed = subtype.parse(inp)
            if parsed is not None:
                return parsed
>       raise InvalidPathException(f"Could not parse path segment {inp}")
E       inmanta.util.dict_path.InvalidPathException: Could not parse path segment neighbors[ip=2
@wouterdb
Copy link
Contributor

wouterdb commented Apr 1, 2025

Hey team! Please add your planning poker estimate with Zenhub @Hugo-Inmanta @jptrindade

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

No branches or pull requests

2 participants