Skip to content

fix(qrcode): close embedded image file before cleanup - #4162

Merged
crazywoola merged 1 commit into
langgenius:mainfrom
Wang-MuFF:fix/qrcode-close-embedded-image
Nov 2, 2026
Merged

crazywoola merged 1 commit into
langgenius:mainfrom
Wang-MuFF:fix/qrcode-close-embedded-image

Conversation

@Wang-MuFF

Copy link
Copy Markdown
Contributor

Summary

Fixes #4161.

Close the embedded-image temporary file before generating the QR code and running cleanup. The existing handle stays open until after os.unlink, causing embedded-image invocations on Windows to raise PermissionError: [WinError 32] instead of completing normally.

Use a context manager to flush and close the temporary file before qrcode/Pillow reads it. The existing cleanup and QR generation behavior remain in place.

Release Notes

Fix QRCode generation with an embedded image failing during temporary-file cleanup on Windows.

Change Type

  • Non-LLM plugin (tools, extensions, datasource, etc.)

Screenshots / Videos

Scenario Before After
Valid embedded PNG Invocation raises Windows file-lock error during cleanup Returns PNG containing the embedded image and completes
Invalid image bytes Cleanup error replaces the normal tool failure Returns the existing Failed to generate QR code message
Plain QR, all four error-correction levels Returns PNG Unchanged

Version

  • Bump the top-level manifest version from 0.1.8 to 0.1.9.
  • Declare dify_plugin>=0.10.2,<0.11.0 and update lock metadata. No locked dependency versions changed.

Testing

  • Clean local packaged-plugin runtime: Python 3.12.10, Dify Plugin SDK 0.10.2, qrcode 8.2, Pillow 13.0.0.

  • Full Dify deployment / SaaS.

  • Real SDK tests use actual File downloads from a local HTTP server and qrcode/Pillow image generation. The two embedded-image cases fail on the unchanged source on Windows; all six cases pass with the fix.

  • Controls cover L/M/Q/H error correction, PNG decoding and filename metadata. The embedding case checks the returned image's center pixel to verify that the supplied image was actually used.

  • New tests pass Black and Ruff; git diff --check passes.

  • Official Dify CLI v0.6.13 packages the staged plugin; its extracted artifact installs in a fresh frozen environment and passes all six tests.

  • The extracted artifact's real serverless /health returns 200. HTTP /invoke downloads the image, returns a decodable PNG through the SDK's blob-chunk protocol and ends cleanly.

@crazywoola
crazywoola deployed to tools/qrcode November 2, 2026 02:31 — with GitHub Actions Active
@crazywoola
crazywoola merged commit aff2685 into langgenius:main Nov 2, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
tools/qrcode — 60065eec Deployed Nov 2, 2026 by crazywoola via test (tools/qrcode) #2953
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.

QRCode embedded-image invocations raise a Windows file-lock error during cleanup

2 participants