fix: KeyError when accessing overseas balance output2[0] #41

Closed
opened 2026-02-05 00:01:11 +09:00 by agentson · 0 comments
Collaborator

Priority: CRITICAL

Problem

# src/main.py:98
total_eval = float(output2[0].get("frcr_evlu_tota", "0"))
KeyError: 0

Docker 로그에서 반복적으로 발생 (약 15% 빈도):

ERROR | Unexpected error for AAPL: 0
KeyError: 0

Root Cause

output2 = balance_data.get("output2", [{}])가 리스트가 아닌 딕셔너리를 반환할 때 output2[0] 접근이 실패

Solution

# Handle both list and dict response formats
if isinstance(output2, list) and output2:
    balance_info = output2[0]
elif isinstance(output2, dict):
    balance_info = output2
else:
    balance_info = {}

Files

  • src/main.py: Line 97-100

Tests

  • Add test case for dict-type output2 response
  • Verify no KeyError with empty/None output2
## Priority: CRITICAL ## Problem ```python # src/main.py:98 total_eval = float(output2[0].get("frcr_evlu_tota", "0")) KeyError: 0 ``` Docker 로그에서 반복적으로 발생 (약 15% 빈도): ``` ERROR | Unexpected error for AAPL: 0 KeyError: 0 ``` ## Root Cause `output2 = balance_data.get("output2", [{}])`가 리스트가 아닌 딕셔너리를 반환할 때 `output2[0]` 접근이 실패 ## Solution ```python # Handle both list and dict response formats if isinstance(output2, list) and output2: balance_info = output2[0] elif isinstance(output2, dict): balance_info = output2 else: balance_info = {} ``` ## Files - `src/main.py`: Line 97-100 ## Tests - Add test case for dict-type output2 response - Verify no KeyError with empty/None output2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#41