fix(im): deliver artifacts/presented files with real filename extension - #512
Merged
Conversation
Feishu (and every send_file connector) derives the delivered file's identity and inline preview from the file_name we send. The artifact display name is often a human title with no extension, so it was sent as e.g. 'Quarterly Report' and Feishu could not open the preview. - save_artifact: prefer the real file basename from entry_file/path, fall back to the display name only when that basename has no extension. - present_file: derive a missing extension from the mime type. Adds regression tests in test_im_outbound_files.py and test_im_outbound_presented.py. Fixes #511
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 #511. Feishu (and every
send_fileconnector) derives the delivered file's identity and inline preview from thefile_namewe send. The artifact display name is often a human title with no extension, so it was sent as e.g.Quarterly Reportand Feishu could not open the preview.save_artifact(_try_deliver): prefer the real file basename fromentry_file/path; fall back to the display name only when that basename has no extension.present_file(_try_deliver_presented): derive a missing extension frommime_typeviamimetypes.guess_extension.The broken
filenamewas set in the platform-agnosticIMArtifactDispatcher, so this also hardens Slack/Discord/Teams/DingTalk.Test plan
test_im_outbound_files.pyandtest_im_outbound_presented.py:entry_filefilenameentry_filetakes priority over a display name that already has an extensionpresent_filewith extensionlessfilename→ extension filled frommime_typefilename→ not double-appendeduv run pytest tests/integration/test_im_outbound_files.py tests/integration/test_im_outbound_presented.py→ 22 passedruff check+ruff format --checkclean on changed files