Better Error handling for empty token list in Messaging send_each_multicast

Open
#792 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start in firebase_admin/messaging.py at send_each_multicast, around the linked line, and trace how an empty device-token list reaches send_each and the thread pool. Compare the alternative location in send_each. Done means an empty list produces a descriptive ValueError instead of the current unknown max_workers error.

Written by the indexing model from the issue text.

Description

api: messaging type: feature request

Problem
Non-descriptive error message returned when sending multicast message with empty device token list. Currently the empty list of tokens propagates throughout the code and results in an Unknown Error type with a vague error message as follows: "Unknown error while making remote service calls: max_workers must be greater than 0". This error seems to originate here as the Threadpool is created with max_workers based on the length of the messages parameter, which is ultimately dependent on the number of tokens in the Message object.

Describe the solution you'd like
Check the length of device tokens directly in the send_each_multicast method and return a descriptive ValueError in the event of an empty list. here

Describe alternatives you've considered
Check the length of the message directly in the send_each class method here.

Dominant language
Python
Stars
1.2k
Forks
359
Avg merge
5d 6m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-python

All issues in firebase/firebase-admin-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.