Skip to content

fix: remove redundant .to_dict() in list_tasks API#667

Open
lidaye910416 wants to merge 1 commit into
666ghj:mainfrom
lidaye910416:fix/list_tasks-to-dict-error
Open

fix: remove redundant .to_dict() in list_tasks API#667
lidaye910416 wants to merge 1 commit into
666ghj:mainfrom
lidaye910416:fix/list_tasks-to-dict-error

Conversation

@lidaye910416
Copy link
Copy Markdown

Fix: Remove redundant .to_dict() in list_tasks API

Problem

The /api/graph/tasks endpoint throws AttributeError: 'dict' object has no attribute 'to_dict'.

Root Cause

TaskManager.list_tasks() already returns serialized dicts via .to_dict() at line 172 in task.py:

return [t.to_dict() for t in sorted(tasks, ...)]

But the API endpoint in graph.py:562 calls .to_dict() again on each item:

"data": [t.to_dict() for t in tasks],  # t is already a dict!

Fix

Simply return tasks directly since it is already a list of dicts.

Testing

  • Before: curl /api/graph/tasks -> 500 Error
  • After: curl /api/graph/tasks -> {"success": true, "data": [], "count": 0}

TaskManager.list_tasks() already returns serialized dicts, so calling
.to_dict() on each item causes AttributeError: 'dict' object has no
attribute 'to_dict'

Fixes: AttributeError in /api/graph/tasks endpoint
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.

1 participant