ITADN

[bug] OpenAPI spec inaccuracies: several required fields return null (causes strict-typed SDKs to crash)

#30823Closedboul2gom 创建于 11 天前
B
boul2gomcommented
### I have searched the existing issues, both open and closed, to make sure this is not a duplicate report. - [x] Yes ### The bug When generating a strictly-typed client SDK (in Rust, using schemars and the official immich-openapi-specs.json), the generated code panics during JSON deserialization on several endpoints. The issue is that the Immich API returns null for various fields, but these fields are not marked as nullable: true (nor as type: ["string", "null"]) in the OpenAPI specification. Strongly-typed languages (Rust, Go, Swift, etc.) trust the spec and expect the strict type (e.g., DateTime, string, integer), causing immediate crashes when encountering null. Check immich-openapi-specs.json: these fields are defined as standard types without the nullable flag. Affected DTOs & Fields Here is the exhaustive list of fields we had to manually patch as nullable in our SDK generator to prevent crashes: In User-related DTOs (UserResponseDto, UserAdminResponseDto, PartnerResponseDto, etc.): - deletedAt - profileChangedAt - profileImagePath - oauthId - quotaSizeInBytes - quotaUsageInBytes - storageLabel - license - avatarColor In Album-related DTOs (AlbumResponseDto): - albumThumbnailAssetId Expected behavior If the backend intentionally returns null for these properties (which makes sense for an empty album or a user without a quota/deletion date), the OpenAPI specification should reflect this by marking them as nullable. In NestJS / @nestjs/swagger, this can usually be fixed by adding nullable: true to the @ApiProperty() decorator for these specific DTO fields ### The OS that Immich Server is running on Debian ### Version of Immich Server v3.1.0 ### Version of Immich Mobile App v3.1.0 ### Platform with the issue - [x] Server - [ ] Web - [ ] Mobile ### Device make and model _No response_ ### Your docker-compose.yml content ```YAML Not relevant ``` ### Your .env content ```Shell Not relevant ``` ### Reproduction steps Spin up an Immich instance (v3.1.0). Call POST /api/auth/admin-sign-up (or create a new user). Observe the JSON response (UserAdminResponseDto / UserResponseDto). Fields like deletedAt, license, quotaSizeInBytes, etc., are returned as null. Call POST /api/albums. Observe the JSON response (AlbumResponseDto). The field albumThumbnailAssetId is returned as null since the album is empty. ### Relevant log output ```shell ``` ### Additional information _No response_
关闭于 10 天前 3 条评论