Uncaught exception when a component has a property whose getter raises (intended?)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
Research direction
Start with the supplied app.py reproducer and trace the member-enumeration path used by bare invocation and --help. Compare that path with the direct greet call, then add coverage for a raising property; done means help and bare invocation handle the getter failure according to the chosen behavior while greet still works.
Written by the indexing model from the issue text.
Description
When a component has a @property whose getter raises, fire.Fire(component) crashes with the property's raw traceback on bare invocation and on --help, instead of showing usage/help. A direct call to an unrelated method works fine.
Repro (fire 0.7.1):
import fire
class App:
@property
def status(self):
raise RuntimeError("backend unavailable") # e.g. a lazy / fallible getter
def greet(self, who="world"):
return f"hi {who}"
if __name__ == "__main__":
fire.Fire(App())
$ python app.py --help
...
value = getter(object, key)
File "app.py", line 5, in status
raise RuntimeError("backend unavailable")
RuntimeError: backend unavailable
$ python app.py greet # works
hi world
Fire enumerates members (and reads property values) during help/listing, so any property getter that can raise (lazy config, DB or network access, etc.) takes down --help and bare invocation, even though those properties are never invoked.
Is this intended, or should Fire surface a clean error (or skip properties that raise) during member enumeration? Happy to send a PR if a fix would be welcome.
Found via automated analysis and confirmed with the reproducer above on fire 0.7.1.
- Dominant language
- Python
- Stars
- 28.2k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/python-fire
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
google/python-fire#693 ·
-
Release 0.7.2? Open
Difficulty 3/5 1-2 days Newbie friendliness 38/100
google/python-fire#698 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
google/python-fire#665 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
google/python-fire#659 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
google/python-fire#643 · 4 comments · 5 reactions ·
All issues in google/python-fire
Similar issues
-
sponsored
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Diaoul/subliminal#1382 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/agentscope#2775 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100