ホーム 暮らし [For ComfyUI Beginners] Did IP-Adapter-Flux break after updating to the latest version? A super concrete guide to a complete recovery with just 2 lines of copy-paste

[For ComfyUI Beginners] Did IP-Adapter-Flux break after updating to the latest version? A super concrete guide to a complete recovery with just 2 lines of copy-paste

八木 麻衣 八木 麻衣 • 更新: • 公開: • 読了約 30 分
目次

The moment I updated ComfyUI to the latest version, the IP-Adapter-Flux workflow that had been working until then stopped with a red error. I also fell into that pattern often called "update phobia" in the community. But to give you the conclusion,all 3 samples will be restored with just a 2-line code fix.

This article is structured so that even beginners who have "almost never written Python" can reach the goal just by copy-pasting in order. I myself have memories of struggling when ComfyUI errors occurred and investigating with Gemini, only to find that version management was the main countermeasure, and Gemini couldn't get to the root cause. Since ClaudeCode looks at all ComfyUI files (the contents of custom node scripts and workflows), it became easy to solve problems through code modification. At worst, you can just reinstall the custom node you messed with, and if you take backups and make it possible to roll back, you're golden. We will clear up the 2 errors in the order of: understanding the cause -> policy for countermeasures -> concrete file modification procedures.

1. Verification Environment

n9fb08ff30917

Item Content OS Windows ComfyUI ComfyUI_windows_portable (latest version) Old version coexistence ComfyUI_windows_portable_3.13 (kept the whole folder) Target custom nodeShakker-Labs/ComfyUI-IPAdapter-Flux Model flux1-dev-fp8-e4m3fn.safetensors ComfyUI-Manager v3.40 Tested workflows ipadapter_example.json / ipadapter_example_start_end_percent.json / multi-ipadapter_example.json

The editor can be the standard Notepad, but I strongly recommend VS Code, Sakura Editor, Notepad++, etc., where you can see line numbers (because it is harder to make mistakes in the modification points).

2. What happened — The situation where errors chained

The trigger was a security alert from ComfyUI Manager:

[Security Alert] ComfyUI outdated. Installations blocked (update allowed).
Update ComfyUI for normal operation.

This is a security enhancement feature from ComfyUI Manager v3.38 onwards, where if the main ComfyUI is older than v0.3.76, it is judged as "too old to be used safely" and the installation of custom nodes is completely blocked (only updating the main body is exceptionally permitted).

So, following the alert, I updated the main body to the latest version. Then, the moment I executed the IP-Adapter-Flux sample ipadapter_example.json, other errors appeared one after another.

Error 1

AttributeError: 'DoubleStreamBlock' object has no attribute 'flipped_img_txt'
 File "...\ComfyUI-IPAdapter-Flux\flux\layers.py", line 31, in init
 self.flipped_img_txt = original_block.flipped_img_txt

Error 2

TypeError: forward_orig_ipa() got an unexpected keyword argument 'timestep_zero_index'
 File "...\ComfyUI\comfy\ldm\flux\model.py", line 406, in _forward
 out = self.forward_orig(img, img_ids, context, txt_ids, timestep, y, guidance,
 control, timestep_zero_index=timestep_zero_index, ...)

In short, it is a state where "the internal API of the ComfyUI main body has been updated, but the IP-Adapter-Flux side is still calling it assuming the old API". Since it is the custom node side that is broken, it will be fixed if you rewrite only 2 places here to match the latest main body.

3. Error cause ① — flipped_img_txt attribute disappeared

The DoubleStreamBlock class in comfy/ldm/flux/layers.py of the latest version of ComfyUI has changed as follows due to refactoring.

  • The constructor no longer accepts the flipped_img_txt argument

  • As a result, it no longer holds the instance attribute self.flipped_img_txt

  • Inside forward(), it is hardcoded to slice in the order of (txt_q, img_q) concatenation + txt_attn, img_attn (equivalent to flipped_img_txt=False in the old code)

However, since the IP-Adapter-Flux side goes to read original_block.flipped_img_txt with the "assumption that the attribute exists", it crashes with an AttributeError.

This is a known issue also reported in upstream Issue #105.

4. Policy for countermeasure ①

We will rewrite it using Python's getattr() function to return a default value if the attribute does not exist. The default is False.

The reason why False is fine is that the latest version of ComfyUI's DoubleStreamBlock.forward() has been fixed to a concatenation order equivalent to the old code's flipped_img_txt=False. The IP-Adapter side also needs to match this, and returning False makes the behavior perfectly consistent with the current core (when using the standard FLUX model).

5. Specific handling details ①

Target file for modification

D:\Comfyui\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-IPAdapter-Flux\flux\layers.py

Location to modify: Line 31 (inside the init method)

Before modification

python

self.flipped_img_txt = original_block.flipped_img_txt

After modification

python

self.flipped_img_txt = getattr(original_block, 'flipped_img_txt', False)

Procedure

  1. Open the above file in an editor

  2. Find line 31 (the line starting with self.flipped_img_txt =)

  3. Replace the entire line with the modified content

  4. Save the changes

  5. Perform a full restart of ComfyUI (close the command prompt window and launch it again)

As a note, please maintain the spaces at the beginning of the line (indentation, 8 half-width spaces) as they are. Since indentation is part of Python's syntax, any misalignment will cause another error.

6. Error cause ② — The timestep_zero_index argument was added

A new keyword argument timestep_zero_index=None has been added to the signature of the forward_orig method in the latest ComfyUI's comfy/ldm/flux/model.py. This is a value used for reference image conditioning in Flux Kontext, and the caller (line 406 of the same file) also passes this argument.

However, IP-Adapter-Flux performs a "monkey patch" in utils.py where it replaces the entire forward_orig with its own forward_orig_ipa. This is achieved using the standard ComfyUI mechanism called add_object_patch, which is done to inject IP-Adapter logic (adapters' image embedding injection).

In other words, the latest core comes calling saying "I'm passing timestep_zero_index=...", but the replacement forward_orig_ipa side is designed without accepting that argument, which is the structure that causes it to crash with a TypeError: unexpected keyword argument.

7. Strategy for Countermeasure ②

We will add one line, timestep_zero_index=None, to the signature of forward_orig_ipa so that it can accept the argument.You don't need to use it inside the function.

The reason is that timestep_zero_index is a value for the Flux Kontext reference image (ref_latents) feature, and in IP-Adapter-only workflows (which applies to all 3 samples here), None is always passed from the caller. By simply accepting and ignoring it, the behavior matches the original forward_orig.

The advanced application of "wanting to use IP-Adapter and Flux Kontext at the same time" is out of scope here. If you want to achieve that, you will need to wait for an upstream fix or perform a full-scale update by rewriting the entire forward_orig_ipa to the latest specifications yourself.

8. Concrete Countermeasure Details ②

Target file for modification

D:\Comfyui\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-IPAdapter-Flux\utils.py

Location to modify: The argument list for def forward_orig_ipa( around line 48

Before modification

python

def forward_orig_ipa(
 self,
 img: Tensor,
 img_ids: Tensor,
 txt: Tensor,
 txt_ids: Tensor,
 timesteps: Tensor,
 y: Tensor,
 guidance: Tensor|None = None,
 control=None,
 transformer_options=,
 attn_mask: Tensor = None,
) -> Tensor:

After modification

python

def forward_orig_ipa(
 self,
 img: Tensor,
 img_ids: Tensor,
 txt: Tensor,
 txt_ids: Tensor,
 timesteps: Tensor,
 y: Tensor,
 guidance: Tensor|None = None,
 control=None,
 timestep_zero_index=None,
 transformer_options=,
 attn_mask: Tensor = None,
) -> Tensor:

In other words, just insert one new line, timestep_zero_index=None, right after control=None, and right before transformer_options=,.

Steps

  1. Open the file above in an editor

  2. Search for the line def forward_orig_ipa(

  3. Insert the new line timestep_zero_index=None, into the argument list below it, between control=None, and transformer_options=,

  4. Save the changes

  5. Completely restart ComfyUI

Again, please ensure the indentation at the beginning of the line (4 half-width spaces) matches the number of spaces in the other argument lines. If you copy and paste, it will happen automatically.

Verification

Once you restart ComfyUI, it is safest to test in the following order.

  1. Load ipadapter_example.json and Queue Prompt → Confirm it completes successfully

  2. Next, run ipadapter_example_start_end_percent.json

  3. Finally, run multi-ipadapter_example.json

Since all three follow the same code path (the replaced forward_orig_ipa and DoubleStreamBlockIPA), if the first one works, the remaining two should work as well. The start/end_percent feature and multi-IP-Adapter feature are self-contained within IP-Adapter-Flux and are implemented independently of the ComfyUI core API changes, so no additional modifications are required.

9. Summary — Why I didn't choose to 'revert to the old version'

At first, I considered the workaround of 'lowering security and continuing to use the old version of ComfyUI.' This involves changing the security_level in config.ini to weak. However, after investigation, I found that this is a dead end that only works in the short term.

There are three reasons.

(1) The weak setting is automatically reverted Since ComfyUI Manager v3.38, the specification is to automatically raise the weak/normal- setting to normal upon startup. You cannot bypass this just by modifying the configuration file.

(2) Downgrading the Manager means losing security patches The only remaining workaround is to downgrade the Manager itself to v3.37 or earlier, but that means losing the user data protection patch introduced in v3.38. The official stance is that this is clearly discouraged.

(3) You will be left behind by the version that the entire ecosystem assumes Almost all new models and new custom nodes are released with the assumption of the 'latest ComfyUI.' If you stay on an old version, you will eventually get stuck elsewhere.

On the other hand, the method in this article (patching custom nodes with one or a few lines to keep up with the latest core) has the following benefits:

  • The scope of the fix is local and has almost no side effects

  • If an official patch is released upstream, it will be automatically overwritten by the Manager's Update button (you can discard your own patch)

  • When you encounter the same pattern of issues, you can reuse the troubleshooting steps

This is overwhelmingly advantageous in the long run.

Completion Checklist
  • Rewrote line 31 of flux/layers.py to the getattr version

  • Added timestep_zero_index=None, to forward_orig_ipa in utils.py

  • Completely restarted ComfyUI

  • Confirmed successful generation with ipadapter_example.json

Since I only managed to get it running, I will be testing plenty of prompts and features from here on out. For now, I just changed the appearance without changing the style randomly.

In conclusion

For those who feel 'scared to touch custom node code,' this fix is a great exercise. By following the Python conventions line by line, you can experience that 'ComfyUI is just a Python app,' and your ability to troubleshoot similar errors on your own will improve significantly.

In the ComfyUI community, there is always a lag between 'core update' and 'waiting for custom node support.' Whether or not you can bridge that gap yourself is a major turning point in truly mastering ComfyUI. I hope this article serves as your first step.

References:

  • Shakker-Labs/ComfyUI-IPAdapter-Flux

  • Issue #105: AttributeError 'flipped_img_txt'

  • ComfyUI-Manager v3.38 userdata security migration

同じカテゴリの記事

八木 麻衣
トレンドリサーチャー 八木 麻衣
プロフィールを見る →

全記事の事実確認を担当。一次情報・公式発表・公開資料の三点を確認できない場合は公開を見送る判断をします。

おすすめの関連記事