Skip to content

fix: append directory type annotation to internal files endpoint (CORE-71)#13305

Merged
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
Abdulrehman-PIAIC80387:fix/load-image-output-missing-preview-13078
Apr 19, 2026
Merged

fix: append directory type annotation to internal files endpoint (CORE-71)#13305
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
Abdulrehman-PIAIC80387:fix/load-image-output-missing-preview-13078

Conversation

@Abdulrehman-PIAIC80387
Copy link
Copy Markdown
Contributor

@Abdulrehman-PIAIC80387 Abdulrehman-PIAIC80387 commented Apr 6, 2026

Summary

Fixes #13078

Problem

The Load Image (from Outputs) node was completely broken — selecting any image from the dropdown resulted in:

  1. 404 Not Found in the browser console when trying to preview the image
  2. "Invalid image file" validation error preventing workflow execution

Root cause: The /internal/files/{directory_type} endpoint in api_server/routes/internal/internal_routes.py (line 70) returned plain filenames like image.png. However, LoadImageOutput inherits from LoadImage, which uses folder_paths.get_annotated_filepath() and folder_paths.exists_annotated_filepath() to resolve file paths. These functions rely on a [directory_type] suffix convention (e.g., image.png [output]) to determine which directory to look in.

Without the annotation, the system defaulted to looking in the input directory instead of the output directory, so:

  • The frontend built incorrect preview URLs (type=input instead of type=output), causing 404 errors
  • VALIDATE_INPUTS couldn't find the file in the input folder, causing validation failures

Fix

Changed the response format in api_server/routes/internal/internal_routes.py line 70 from:

return web.json_response([entry.name for entry in sorted_files], status=200)

to:

return web.json_response([f"{entry.name} [{directory_type}]" for entry in sorted_files], status=200)

This appends the directory type annotation (e.g., [output], [input], [temp]) to each filename, allowing annotated_filepath() in folder_paths.py to correctly resolve the file to the right directory.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

The change modifies the /internal/files/{directory_type} endpoint to alter its response format. Instead of returning only each visible file's name, the endpoint now returns a list of strings formatted as "{entry.name} [{directory_type}]". All existing functionality is preserved, including filtering of non-hidden files, sorting by descending modification time, and validation and error handling for the directory_type parameter.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR directly addresses issue #13078 by implementing the exact fix proposed: appending [directory_type] suffix to filenames so the endpoint returns annotated filepaths.
Out of Scope Changes check ✅ Passed The PR contains only the single, focused change to the response format of the /internal/files/{directory_type} endpoint, directly addressing the linked issue with no extraneous modifications.
Description check ✅ Passed The PR description clearly explains the problem, root cause, and solution related to the endpoint changes.
Title check ✅ Passed The title accurately describes the main change: appending directory type annotation to the internal files endpoint response, which is the core fix addressing the issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Abdulrehman-PIAIC80387 Abdulrehman-PIAIC80387 changed the title fix: append directory type annotation to internal files endpoint resp… fix: append directory type annotation to internal files endpoint Apr 6, 2026
@Abdulrehman-PIAIC80387
Copy link
Copy Markdown
Contributor Author

Hi, just checking in — this is a small one-line fix for #13078 which multiple users have confirmed works. Would appreciate a review when you get a chance. Thanks!

@alexisrolland alexisrolland changed the title fix: append directory type annotation to internal files endpoint fix: append directory type annotation to internal files endpoint (CORE-71) Apr 18, 2026
@alexisrolland
Copy link
Copy Markdown

Tested and it works as expected. Lgtm for merging.

@comfyanonymous comfyanonymous merged commit 138571d into Comfy-Org:master Apr 19, 2026
14 checks passed
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.

Load Image (From Output) has no Preview

3 participants