Skip to content

fix: split subfolder from filename in getMediaUrl for correct /api/view thumbnails - #16935

Closed
phazei wants to merge 1 commit into
Comfy-Org:mainfrom
phazei:fix/widget-select-subfolder-thumbnail-url
Closed

phazei wants to merge 1 commit into
Comfy-Org:mainfrom
phazei:fix/widget-select-subfolder-thumbnail-url

Conversation

@phazei

@phazei phazei commented Sep 4, 2026

Copy link
Copy Markdown

Summary

Fix broken thumbnails in the image combo dropdown for values containing subfolder paths (e.g. subfolder/image.png).

Supersedes #12438, which was closed due to branch drift — this branch is rebased onto current main and contains only the single focused commit.

Changes

getMediaUrl in useWidgetSelectItems.ts now uses the existing parseImageWidgetValue utility to split subfolder-prefixed filenames into separate filename and subfolder query parameters when constructing /api/view URLs. Added a test case for nested subfolder paths.

Review Focus

The /api/view endpoint calls os.path.basename(filename) on the filename param, stripping any embedded path components. It already supports a separate subfolder query parameter (and parseImageWidgetValue already exists for exactly this split), but getMediaUrl wasn't using it. Flat filenames are unaffected — parseImageWidgetValue returns an empty subfolder string and no param is added.

Fixes #12437

E2E test rationale: The fix modifies pure URL construction logic in getMediaUrl, which is fully validated by the added unit test. An E2E regression test would require a backend serving images from nested subfolders to verify thumbnail rendering, making it fragile and environment-dependent. The unit test directly asserts the correct filename and subfolder query parameter splitting, which is the root cause of the bug.

@phazei
phazei requested a review from a team September 4, 2026 06:30
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle: ⚠️ Size data collection failed — check the CI workflow logs

⚡ Performance: ⚠️ Performance tests failed — check the CI workflow logs

🔬 E2E Coverage: ⚠️ Coverage collection failed — check the CI workflow logs

🎭 Playwright: ⏳ Running...

🎨 Storybook: ❌ Failed

❌ Storybook failed. Open the workflow run and fix the build before merging.

Details

⏰ Completed at: 11/05/2026, 01:07:53 AM UTC

Links

@phazei

phazei commented Sep 4, 2026

Copy link
Copy Markdown
Author

@DrJKL This is the fresh PR you requested when closing #12438 — rebased onto current main with just the single focused commit (getMediaUrl fix + regression test).

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: fc992dca-0629-4697-99e4-94c5b837a12a
📥 Commits

Reviewing files that changed from the base of the PR and between e59dd60 and e7d585f.

📒 Files selected for processing (2)
  • src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectItems.test.ts
  • src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectItems.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The widget selector parses image paths before constructing /api/view preview URLs. It sends the basename and subfolder separately and preserves type handling. A regression test checks the URL for a nested path.

Changes

Media preview URL handling

Layer / File(s) Summary
Parse nested preview paths
src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectItems.ts, src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectItems.test.ts
getMediaUrl uses parseImageWidgetValue to build query parameters from the parsed filename and type, and adds the subfolder when present. A regression test checks basename extraction, encoded subfolder handling, and type=input.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: austinmroz

Merge Risk: ⚪ Minimal · up to e7d58

Nested image previews now send the filename and subfolder separately. No merge-blocking issue was established; proceed with normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e7d58

The fix uses an established media URL format and introduces no new endpoint. However, newly forwarded subfolder paths rely on server-side containment and access checks that could not be verified for the deployed service.

Retained concerns

  • Low · security · inferred: Dropdown previews now forward unsanitized subfolder paths, including parent-relative components, to the media endpoint. Safe resolution depends on backend containment and ownership enforcement that remain unverified. This is an unresolved boundary dependency, not a confirmed path-traversal vulnerability.
Security review details

Security Blast Radius

  • inferred — The demonstrated surface is browser media requests to the existing /api/view endpoint. Any unauthorized file or workspace exposure would depend on backend resolution and authorization; arbitrary-file reads, cross-tenant access, and privilege escalation are not established.

Security Findings and Attack Paths

  • observed — The traversal candidate remains deferred. Frontend forwarding and request-capable rendering are established, but deployed containment and authorization are not. The supplied security assessment contains no retained finding.

Trust Boundaries and Controls

  • observed — Separately forwarded widget paths predate this PR in the unchanged video URL consumer. The generated media contract documents workspace selection and authorization errors, but documentation does not prove enforcement. The PR adds another caller using this established path contract, not a new server capability.

Hardening Proposals

  • proposed — Validate the deployment-matching media handler against parent-relative and absolute subfolders, annotated media-root selection, and unauthorized workspace requests. Establish canonical path containment and ownership enforcement server-side rather than treating frontend encoding as a security control.
🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the getMediaUrl change and its purpose: separating subfolder paths from filenames for /api/view thumbnails.
Description check ✅ Passed The description includes the summary, changes, review focus, issue reference, and rationale for omitting an E2E test. It explains the fix and its scope. The template’s optional screenshot section and …
Linked Issues check ✅ Passed Issue #12437 requires thumbnails to load for combo values with subfolder paths. getMediaUrl now uses parseImageWidgetValue to send the basename as filename and adds subfolder when present. The…
Out of Scope Changes check ✅ Passed The source change and regression test both support issue #12437. The diff contains no unrelated changes.
End-To-End Regression Coverage For Fixes ✅ Passed The title and commit subject use the bug-fix signal “fix,” and the changed files are under src/ with no browser_tests/ file. However, the PR description gives a concrete reason for not adding an e…
Website End-To-End Regression Coverage ✅ Passed No website runtime files changed. The provided changed-file list contains only src/renderer/extensions/vueNodes/widgets/composables/useWidgetSelectItems.ts and its test, so this check does not apply…
Adr Compliance For Entity/Litegraph Changes ✅ Passed The changed files are related to node widgets, so the check applies. The supplied change details show URL construction in getMediaUrl and a regression test. They do not show entity-state mutations, …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
🧰 Additional context used
📚 Code guidelines (3)
docs/guidance/testing-principles.md — auto-discovered
docs/guidance/typescript.md — auto-discovered
src/AGENTS.md — auto-discovered

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

@phazei
phazei force-pushed the fix/widget-select-subfolder-thumbnail-url branch from 0dc861b to e59dd60 Compare September 9, 2026 22:52
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@phazei
phazei force-pushed the fix/widget-select-subfolder-thumbnail-url branch from e59dd60 to e7d585f Compare October 6, 2026 00:03
@phazei

phazei commented Nov 7, 2026

Copy link
Copy Markdown
Author

Closing as superseded: #22107 and #22331 fixed the same subfolder-in-filename bug in useWidgetSelectItems. This PR's regression test passes on current main with no changes. Thanks @jaeone94.

@phazei phazei closed this Nov 7, 2026
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.

WidgetSelectDropdown.getMediaUrl() does not split subfolder from filename, breaking thumbnails for subfolder-prefixed combo values

1 participant