feat(tapd): accept local image paths in image_url and auto-upload to TAPD image hosting - #14
Open
RaphLorr wants to merge 1 commit into
Open
Conversation
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
image_url/image_urls/mediapreviously required an already-public URL, so embedding a local screenshot meant standing up an external image host (e.g. an object-storage bucket with public read). That pushes screenshots outside the workspace's own permission model.POST /files/upload_image, and the returnedimage_srcis embedded instead./tfl/are passed through untouched, so this is backward compatible.Changes
tapd.py: newTAPDClient.upload_image(). It usesmultipart/form-dataand cannot reuse_make_request(), which sendsjson=and pinsContent-Type: application/json— that header preventsrequestsfrom generating a multipart boundary, so it is explicitly dropped here.server.py:_is_local_image_path()and_upload_local_images(), hooked into_render_rich_description(). All six write tools inherit the behaviour:create_story_or_task,update_story_or_task,create_bug,update_bug,create_comments,update_comments.server.py: a standaloneupload_imagetool, for callers that want the image path / HTML snippet before composing the description themselves.Behaviour notes
PNG/GIF/JPG/JPEG/BMP, one image per call.stdiomode; the docstring calls it out forstreamable-httpdeployments.<img>. A ticket created with its screenshot silently missing is worse than a failed call the caller can see and retry.video_url/video_urlsstill require an externally reachable URL.Test plan
/tfl/paths not re-uploaded, video items skipped, missingworkspace_idpassthrough, upload failure raises, missingimage_srcraises, oversize raises, uppercase extensions acceptedcreate_bugwithimage_urlset to a local absolute path produced<img src="/tfl/pictures/202608/api_*.png" ... />in the description; verified by reading the bug back through the APIPOST /files/upload_imageworks onapi.tapd.cn(the documentation page describes it on a different host)