[PR #2119] [MERGED] Fix JSON serialization error in bulk import fail info API #2293

Closed
opened 2026-10-28 21:08:42 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/ComfyUI-Manager/pull/2119
Author: @viva-jinyi
Created: 9/1/2025
Status: ✅ Merged
Merged: 9/3/2025
Merged by: @ltdrdata

Base: draft-v4 ← Head: fix/import-bulk-api-error


📝 Commits (2)

  • 3546ceb fix: import failed info bulk api bug fix
  • 93813bb fix: Remove unused ImportFailInfoBulkResponse import

📊 Changes

1 file changed (+12 additions, -6 deletions)

View changed files

📝 comfyui_manager/glob/manager_server.py (+12 -6)

📄 Description

Problem

The /v2/customnode/import_fail_info_bulk endpoint was throwing a JSON serialization error:

[ComfyUI-Manager] Error processing bulk import fail info: Object of type ImportFailInfoItem is not JSON serializable

Root Cause

The error occurred due to a mismatch between the internal data structure and the API specification:

  1. Internal data structure (cm_global.error_dict):

    {
        'name': 'node-name',
        'path': '/path/to/node',
        'msg': 'error message'
    }
    
  2. API spec expects (ImportFailInfoItem):

    {
        'error': 'error string',
        'traceback': 'traceback string'
    }
    
  3. The code was trying to serialize the Pydantic model ImportFailInfoBulkResponse which contained incompatible data structures, causing the serialization failure.

Solution

  • Transform the data from cm_global.error_dict format to match the API specification
  • Map msg field to error field
  • Add empty traceback field when not present
  • Remove Pydantic model serialization and return plain dict directly as JSON

Changes Made

  1. Added data transformation in the bulk endpoint to convert error dict format:

    results[cnr_id] = {
        'error': info.get('msg', ''),
        'traceback': info.get('traceback', '')
    }
    
  2. Removed problematic Pydantic model serialization:

    • Before: return web.json_response(response_data.root)
    • After: return web.json_response(results, content_type="application/json")

Testing

Tested with the following curl command and confirmed it returns proper JSON response without errors:

curl 'http://localhost:8188/api/v2/customnode/import_fail_info_bulk' \
  -H 'Content-Type: application/json' \
  --data-raw '{"cnr_ids":["comfyui-manager","teacache","comfyui-gguf"]}'

Impact

  • Fixes the 500 Internal Server Error when calling the bulk import fail info endpoint
  • Ensures consistent API response format across single and bulk endpoints
  • Maintains backward compatibility with existing API contracts

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/ComfyUI-Manager/pull/2119 **Author:** [@viva-jinyi](https://github.com/viva-jinyi) **Created:** 9/1/2025 **Status:** ✅ Merged **Merged:** 9/3/2025 **Merged by:** [@ltdrdata](https://github.com/ltdrdata) **Base:** `draft-v4` ← **Head:** `fix/import-bulk-api-error` --- ### 📝 Commits (2) - [`3546ceb`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/3546cebb7bc7e0039b558f239d8c2e52ca820c67) fix: import failed info bulk api bug fix - [`93813bb`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/93813bb70b4d05d254b2809f026b3a55c7391ef3) fix: Remove unused ImportFailInfoBulkResponse import ### 📊 Changes **1 file changed** (+12 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `comfyui_manager/glob/manager_server.py` (+12 -6) </details> ### 📄 Description ## Problem The `/v2/customnode/import_fail_info_bulk` endpoint was throwing a JSON serialization error: ``` [ComfyUI-Manager] Error processing bulk import fail info: Object of type ImportFailInfoItem is not JSON serializable ``` ## Root Cause The error occurred due to a mismatch between the internal data structure and the API specification: 1. **Internal data structure** (`cm_global.error_dict`): ```python { 'name': 'node-name', 'path': '/path/to/node', 'msg': 'error message' } ``` 2. **API spec expects** (`ImportFailInfoItem`): ```python { 'error': 'error string', 'traceback': 'traceback string' } ``` 3. The code was trying to serialize the Pydantic model `ImportFailInfoBulkResponse` which contained incompatible data structures, causing the serialization failure. ## Solution - Transform the data from `cm_global.error_dict` format to match the API specification - Map `msg` field to `error` field - Add empty `traceback` field when not present - Remove Pydantic model serialization and return plain dict directly as JSON ## Changes Made 1. Added data transformation in the bulk endpoint to convert error dict format: ```python results[cnr_id] = { 'error': info.get('msg', ''), 'traceback': info.get('traceback', '') } ``` 2. Removed problematic Pydantic model serialization: - Before: `return web.json_response(response_data.root)` - After: `return web.json_response(results, content_type="application/json")` ## Testing Tested with the following curl command and confirmed it returns proper JSON response without errors: ```bash curl 'http://localhost:8188/api/v2/customnode/import_fail_info_bulk' \ -H 'Content-Type: application/json' \ --data-raw '{"cnr_ids":["comfyui-manager","teacache","comfyui-gguf"]}' ``` ## Impact - Fixes the 500 Internal Server Error when calling the bulk import fail info endpoint - Ensures consistent API response format across single and bulk endpoints - Maintains backward compatibility with existing API contracts --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-28 21:08:42 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/ComfyUI-Manager#2293
No description provided.