fix: handle None distribution data in portfolio dashboard#26
Open
themavik wants to merge 1 commit intohummingbot:mainfrom
Open
fix: handle None distribution data in portfolio dashboard#26themavik wants to merge 1 commit intohummingbot:mainfrom
themavik wants to merge 1 commit intohummingbot:mainfrom
Conversation
When asyncio.gather returns exceptions for the token or accounts distribution tasks, the caller sets those variables to None. The dashboard function then crashes with AttributeError: 'NoneType' object has no attribute 'get' because it calls .get() without a None guard. Add None checks consistent with the existing pattern used for history_data on line 646, which already handles this correctly. Fixes hummingbot#24 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
asyncio.gather(return_exceptions=True)returns exceptions for the token or accounts distribution API tasks, the caller inportfolio_command()sets those variables toNone. Thegenerate_portfolio_dashboard()function then crashes with:at line 908 (
accounts_distribution_data.get("distribution", [])).Root Cause
history_dataalready has a None guard on line 646:But
token_distribution_data(line 843-844) andaccounts_distribution_data(line 908-909) are missing the same guard.Changes
Add
if ... else []/if ... else {}guards to the four.get()calls ontoken_distribution_dataandaccounts_distribution_data, consistent with the existing pattern forhistory_data.Test Plan
Fixes #24