Skip to content

results: Bail out gracefully when profile data is missing - #1614

Open
chiruu12 wants to merge 1 commit into
airspeed-velocity:mainfrom
chiruu12:fix/profile-missing-data
Open

results: Bail out gracefully when profile data is missing#1614
chiruu12 wants to merge 1 commit into
airspeed-velocity:mainfrom
chiruu12:fix/profile-missing-data

Conversation

@chiruu12

Copy link
Copy Markdown

Closes #1459.

get_profile indexed _profiles directly and then called .encode() on the result, so a benchmark with no stored profile raised KeyError, and one stored as None raised AttributeError. add_result only writes the entry when the profile is truthy, so both shapes are reachable.

has_profile('absent')  -> None
get_profile('absent')  -> KeyError: 'time_absent'
get_profile(None-valued) -> AttributeError: 'NoneType' object has no attribute 'encode'

It now raises UserError, which main.py already turns into a logged error and a non-zero exit rather than a traceback. Of the three call sites, two guard with has_profile first, and the third is asv profile right after a profiling run, which is the one that surfaced this.

Also corrects the docstring, which promised pstats.Stats but returns raw bytes. get_profile_stats has been the Stats-returning method since #1253.

Added a test covering both shapes. It fails on main with KeyError and passes here.

pytest test/test_profile.py test/test_results.py passes, 11 tests. pre-commit run --files passes on all changed files.

get_profile indexed _profiles directly and called encode on the result,
so a benchmark with no stored profile raised KeyError, and one stored as
None raised AttributeError. add_result only writes the entry when the
profile is truthy, so both shapes are reachable.

It now raises UserError, which main.py already turns into a logged error
rather than a traceback.

Also corrects the docstring, which promised pstats.Stats but returns raw
bytes. get_profile_stats has been the Stats-returning method since airspeed-velocity#1253.
Copilot AI lite review requested due to automatic review settings August 15, 2026 05:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Successfully merging this pull request may close these issues.

MAINT: Bail out more gracefully if profile data isn't present

2 participants