fix(typescript): guard appendFile against null/undefined for optional multipart file uploads#16713
Conversation
… multipart file uploads Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
…leWithMetadata Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Description
Fixes a regression in TypeScript SDK generation (v3.68.0+) where passing
undefinedto an optional multipart file upload field crashes withTypeError: Cannot use 'in' operator to search for 'path' in undefined.The call chain
appendFile("file", undefined)→toMultipartDataPart(undefined)→getFileWithMetadata(undefined)→if ("path" in file)blows up becauseundefinedis not an object.Changes Made
FormDataWrapper.template.ts: Addedif (value == null) { return; }at the top of all 4appendFileimplementations (Node18, Node16, Web, simple). Optional file fields silently skip when null/undefined, restoring pre-3.68.0 tolerance.file.ts—getFileWithMetadata(): Added a null guard that throws a clearError("Cannot upload null or undefined as a file. Ensure the file parameter is provided.")as defense-in-depth iftoMultipartDataPartis called directly.Testing
file.test.ts: 4 tests coveringtoBinaryUploadRequestandtoMultipartDataPartwith null/undefinedformDataWrapper.test.template.ts: tests forappendFilesilently skipping null/undefined in Node18, Web, and default implementationsno-custom-configLink to Devin session: https://app.devin.ai/sessions/4b885de21ac744dbb59164c3ba84d68a