-
-
Notifications
You must be signed in to change notification settings - Fork 253
Description
Bug Report: Missing Closing Parenthesis in Generated Multipart Form Data Code
Summary
The openapi-python-client
generator produces invalid Python syntax when generating multipart form data handling code, specifically missing closing parentheses in files.append()
calls within the to_multipart()
method.
Environment
- openapi-python-client version: 0.25.2
- Python version: 3.x
- Operating System: macOS 24.6.0
OpenAPI Specification
- URL: https://raw.githubusercontent.com/immich-app/immich/refs/heads/main/open-api/immich-openapi-specs.json
- Affected Model:
AssetMediaCreateDto
Bug Description
When generating code for the AssetMediaCreateDto
model, the generator produces malformed Python code in the to_multipart()
method. Specifically, line 180 in the generated file is missing a closing parenthesis:
Generated (incorrect) code:
files.append(("livePhotoVideoId", (None, str(self.live_photo_video_id), "text/plain"))
Expected (correct) code:
files.append(("livePhotoVideoId", (None, str(self.live_photo_video_id), "text/plain")))
Error Details
The missing parenthesis causes a cascade of syntax errors:
SyntaxError: Expected 'else', found ':'
SyntaxError: Unparenthesized generator expression cannot be used here
SyntaxError: Expected ',', found ':'
SyntaxError: Expected ')', found newline
Steps to Reproduce
- Run:
openapi-python-client generate --overwrite --url https://raw.githubusercontent.com/immich-app/immich/refs/heads/main/open-api/immich-openapi-specs.json
- Check the generated file:
immich_client/models/asset_media_create_dto.py
- Look at line 180 in the
to_multipart()
method
Expected Behavior
The generator should produce valid Python syntax with properly closed parentheses.
Actual Behavior
The generator produces invalid Python syntax with missing closing parentheses, causing the generated code to fail linting and runtime checks.
Impact
- Generated code cannot be used without manual fixes
- Breaks automated CI/CD pipelines that rely on generated code
- Requires manual intervention after each code generation
Workaround
Currently, the issue must be manually fixed by adding the missing closing parenthesis to the affected line.
Additional Information
This appears to be a template rendering issue in the multipart form data generation logic. The bug is reproducible and occurs consistently in the same location.