Repository navigation
fix(qrcode): close embedded image file before cleanup - #4162
Merged
crazywoola merged 1 commit intoNov 2, 2026
Merged
Conversation
crazywoola
approved these changes
Nov 2, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 raisePermissionError: [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
Screenshots / Videos
Failed to generate QR codemessageVersion
dify_plugin>=0.10.2,<0.11.0and 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
Filedownloads 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 --checkpasses.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
/healthreturns 200. HTTP/invokedownloads the image, returns a decodable PNG through the SDK's blob-chunk protocol and ends cleanly.