TypeError: string indices must be integers

用户在更新 comfyui-frontend-package 至 1.33.10 后,使用 ComfyUI 内置的 Load 3D 节点时,从节点 image 输出拖线连接到 Preview Image 节点,无法正常生成模型预览图。

TypeError: string indices must be integers, not ‘str’

快速结论:该错误通常出现在 ComfyUI 的 Load 3D 节点中,原因是前端更新后传递给节点的 image 参数从预期字典变成了纯字符串。优先尝试 Workaround 1 —— 临时修改 nodes_load_3d.py 增加类型兼容判断。

问题场景

用户在更新 comfyui-frontend-package1.33.10 后,使用 ComfyUI 内置的 Load 3D 节点时,从节点 image 输出拖线连接到 Preview Image 节点,无法正常生成模型预览图。

报错原文

!!! Exception during processing !!! string indices must be integers, not 'str'
Traceback (most recent call last):
  File "...\ComfyUI\execution.py", line 303, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "...\ComfyUI\execution.py", line 291, in process_inputs
    result = f(**inputs)
  File "...\ComfyUI\comfy_extras\nodes_load_3d.py", line 52, in execute
    image_path = folder_paths.get_annotated_filepath(image['image'])
                                                     ~~~~~^^^^^^^^^
TypeError: string indices must be integers, not 'str'

原因分析

核心原因在于前端(comfyui-frontend-package)与后端 ComfyUI 核心之间对 Load 3D 节点的输入格式约定不一致。在更新后,前端传递给 Load3D 节点的 image 参数变为一个纯字符串类型的文件路径,而后端 nodes_load_3d.pyexecute 函数仍然按照旧协议预期 image 是一个字典,包含 imagemasknormal 等键值对。当代码执行 image['image'] 时,因 image 为字符串而非字典,触发了 TypeError: string indices must be integers, not 'str'

该问题属于前端/后端契约不匹配,并非自定义节点问题。

环境排查

  • ComfyUI 核心版本(检查 comfyui-frontend-package 是否为 1.33.10 或更高版本)
  • Python 版本(通常不影响,但需确认环境一致性)
  • 检查 comfy_extras/nodes_load_3d.py 是否存在(位于 ComfyUI 安装目录下)

解决步骤

  1. Workaround 1 —— 临时修补后端(可优先尝试)
    • 打开 comfy_extras/nodes_load_3d.py 文件。
    • 定位到 execute 方法。
    • 在方法开头添加类型兼容判断:检查 image 是否为 dict。如果是,则按字典方式提取 image/mask/normal 等键;否则将 image 视为字符串直接赋值。
    • 保存文件后重启 ComfyUI。
  2. Workaround 2 —— 版本对齐
    • 如果将 comfyui-frontend-package 单独升级到 1.33.10,建议回退到与当前 ComfyUI 核心版本匹配的前端版本(例如从官方仓库重新安装 ComfyUI portable build)。
    • 已知 1.32.0 版本在部分用户中工作正常,可作为回退参考。

验证方法

修补后,重新从 Load 3D 节点 image 输出拖线到 Preview Image 节点,观察是否能正常生成模型预览图,且后台日志不再出现 TypeError: string indices must be integers 错误。

参考来源

Comfy-Org/ComfyUI #11142

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 9039

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注