这是indexloc提供的服务,不要输入任何密码
Skip to content

Bug: KeyError when accessing "value" column in portfolio overview #2

@cj4c0b1

Description

@cj4c0b1

Description

The portfolio overview page is failing with a KeyError: "value" when trying to calculate the total balance. The error occurs in the portfolio_overview function when attempting to access the "value" column from the portfolio DataFrame.

Steps to Reproduce

  1. Navigate to the portfolio overview page
  2. Apply any filter combination
  3. The error occurs when trying to calculate and display the total balance

Error Log

File "/home/dashboard/frontend/pages/orchestration/portfolio/app.py", line 190, in portfolio_overview
    total_balance_usd = round(portfolio_df["value"].sum(), 2)
                          ~~~~~~~~~~~~^
KeyError: "value"

Expected Behavior

The portfolio overview should display the total balance by summing up the "value" column from the portfolio data.

Possible Causes

  1. The filtered_portfolio_state might not have the expected structure
  2. The token information dictionaries might be missing the "value" key
  3. The portfolio_state_to_df function might not be creating the DataFrame with the expected columns

Additional Context

  • The error occurs in pages/orchestration/portfolio/app.py
  • The portfolio_state_to_df function is responsible for creating the DataFrame
  • Debugging output has been added to help diagnose the issue

Proposed Solution

  1. Add proper error handling for missing "value" key
  2. Validate the input data structure
  3. Provide meaningful error messages when required data is missing

Environment

  • File: /pages/orchestration/portfolio/app.py
  • Function: portfolio_overview()
  • Line: ~190

Next Steps

  • Add validation for input data structure
  • Add error handling for missing "value" key
  • Add unit tests to catch similar issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions