Skip to content

DB pattern matching not working as expected #113

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

Closed
adimaggio2021 opened this issue Jul 3, 2023 · 0 comments · Fixed by #116
Closed

DB pattern matching not working as expected #113

adimaggio2021 opened this issue Jul 3, 2023 · 0 comments · Fixed by #116

Comments

@adimaggio2021
Copy link

I'm writing a function with a realtime DB trigger.

@db_fn.on_value_created(reference="/messages/{user}/{chat_id}/{msg_id}")
def do_work(event: db_fn.Event[Any]) -> None:
    # process event

From reading the docs, I expect this to match on a message pushed to a chat with chat_id. For example, a value created at /messages/user_1/chat_1/msg_a would be captured and the appropriate ids sent to the function.

However, when I attempt to implement this functionality, errors crop up in the pattern matching code:

File "/layers/google.python.pip/pip/lib/python3.11/site-packages/firebase_functions/private/path_pattern.py", line 177, in extract_matches
    matches[segment.trimmed] = path_segments[path_ndx]
                               ~~~~~~~~~~~~~^^^^^^^^^^
IndexError: list index out of range

It seems like the pattern-matching code errors out in this situation where the value created is at a ref with a wildcard in the last path segment. I'm using a workaround right now but thought I'd bring it up as an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant