[PR #3939] [MERGED] fix(server): non-nullable IsOptional #10172

Closed
opened 2026-02-05 14:17:08 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/3939
Author: @mertalev
Created: 9/1/2023
Status: Merged
Merged: 9/1/2023
Merged by: @jrasm91

Base: mainHead: chore/server-isoptional


📝 Commits (10+)

📊 Changes

43 files changed (+271 additions, -243 deletions)

View changed files

📝 cli/src/api/open-api/api.ts (+2 -2)
📝 mobile/openapi/doc/PeopleUpdateItem.md (+1 -1)
📝 mobile/openapi/doc/PersonUpdateDto.md (+1 -1)
📝 mobile/openapi/lib/model/people_update_item.dart (+1 -1)
📝 mobile/openapi/lib/model/person_update_dto.dart (+1 -1)
📝 mobile/openapi/test/people_update_item_test.dart (+1 -1)
📝 mobile/openapi/test/person_update_dto_test.dart (+1 -1)
📝 server/immich-openapi-specs.json (+2 -2)
📝 server/src/domain/album/dto/album-create.dto.ts (+3 -3)
📝 server/src/domain/album/dto/album-update.dto.ts (+4 -4)
📝 server/src/domain/album/dto/album.dto.ts (+3 -3)
📝 server/src/domain/album/dto/get-albums.dto.ts (+3 -3)
📝 server/src/domain/api-key/api-key.dto.ts (+3 -3)
📝 server/src/domain/asset/dto/asset-statistics.dto.ts (+4 -4)
📝 server/src/domain/asset/dto/asset.dto.ts (+4 -3)
📝 server/src/domain/asset/dto/download.dto.ts (+3 -3)
📝 server/src/domain/asset/dto/map-marker.dto.ts (+5 -5)
📝 server/src/domain/asset/dto/time-bucket.dto.ts (+4 -4)
📝 server/src/domain/audit/audit.dto.ts (+3 -2)
📝 server/src/domain/auth/dto/login-credential.dto.ts (+2 -1)

...and 23 more files

📄 Description

Description

class-validator's IsOptional does not validate null inputs, which is problematic as null has different semantics and behavior in JavaScript compared to undefined. This PR adds a custom IsOptional decorator with a nullable option that defaults to false, and replaces existing usages with this.

How Has This Been Tested?

I added modelType: null to the classification section of immich-config.json (aside: the value of this is not actually used, but is assignable in the config). This did not cause any errors on main, but was rejected in this PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/3939 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 9/1/2023 **Status:** ✅ Merged **Merged:** 9/1/2023 **Merged by:** [@jrasm91](https://github.com/jrasm91) **Base:** `main` ← **Head:** `chore/server-isoptional` --- ### 📝 Commits (10+) - [`129aeda`](https://github.com/immich-app/immich/commit/129aedabba7076c73c1eb1451ce02a1067e81c39) custom `IsOptional` - [`484fafa`](https://github.com/immich-app/immich/commit/484fafafec1a85d6daea8ee538c8f2e59c3263d3) added link to source - [`a5034c5`](https://github.com/immich-app/immich/commit/a5034c596c11a97bbcc1c6696c1c4fcdcc8e6adb) formatting - [`f346aa3`](https://github.com/immich-app/immich/commit/f346aa30eabb5b8c805c47f7c8b03bb98aef6b97) Update server/src/domain/domain.util.ts - [`dfe8fd5`](https://github.com/immich-app/immich/commit/dfe8fd544766ecbfe95b2ca26f72682a9894a6dc) nullable birth date endpoint - [`3475bf9`](https://github.com/immich-app/immich/commit/3475bf93cdc548936f8abc58f8049ebd53f40709) made `nullable` a property - [`534591b`](https://github.com/immich-app/immich/commit/534591be8f48f9c6ddfc377f4be7d2d5faec236b) formatting - [`52fe5ec`](https://github.com/immich-app/immich/commit/52fe5ec6287b1459f64600cd1d442f50ccb4b82f) removed unused dto - [`c9e8442`](https://github.com/immich-app/immich/commit/c9e8442de0fe05f1fa8b6e572f04a8e91191c10d) updated decorator arg - [`877d73a`](https://github.com/immich-app/immich/commit/877d73a697250b18c68ee0bd7b2c2b4aa28ef6db) fixed album e2e tests ### 📊 Changes **43 files changed** (+271 additions, -243 deletions) <details> <summary>View changed files</summary> 📝 `cli/src/api/open-api/api.ts` (+2 -2) 📝 `mobile/openapi/doc/PeopleUpdateItem.md` (+1 -1) 📝 `mobile/openapi/doc/PersonUpdateDto.md` (+1 -1) 📝 `mobile/openapi/lib/model/people_update_item.dart` (+1 -1) 📝 `mobile/openapi/lib/model/person_update_dto.dart` (+1 -1) 📝 `mobile/openapi/test/people_update_item_test.dart` (+1 -1) 📝 `mobile/openapi/test/person_update_dto_test.dart` (+1 -1) 📝 `server/immich-openapi-specs.json` (+2 -2) 📝 `server/src/domain/album/dto/album-create.dto.ts` (+3 -3) 📝 `server/src/domain/album/dto/album-update.dto.ts` (+4 -4) 📝 `server/src/domain/album/dto/album.dto.ts` (+3 -3) 📝 `server/src/domain/album/dto/get-albums.dto.ts` (+3 -3) 📝 `server/src/domain/api-key/api-key.dto.ts` (+3 -3) 📝 `server/src/domain/asset/dto/asset-statistics.dto.ts` (+4 -4) 📝 `server/src/domain/asset/dto/asset.dto.ts` (+4 -3) 📝 `server/src/domain/asset/dto/download.dto.ts` (+3 -3) 📝 `server/src/domain/asset/dto/map-marker.dto.ts` (+5 -5) 📝 `server/src/domain/asset/dto/time-bucket.dto.ts` (+4 -4) 📝 `server/src/domain/audit/audit.dto.ts` (+3 -2) 📝 `server/src/domain/auth/dto/login-credential.dto.ts` (+2 -1) _...and 23 more files_ </details> ### 📄 Description ## Description `class-validator`'s `IsOptional` does not validate null inputs, which is problematic as `null` has different semantics and behavior in JavaScript compared to `undefined`. This PR adds a custom `IsOptional` decorator with a `nullable` option that defaults to `false`, and replaces existing usages with this. ## How Has This Been Tested? I added `modelType: null` to the `classification` section of `immich-config.json` (aside: the value of this is not actually used, but is assignable in the config). This did not cause any errors on main, but was rejected in this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:17:08 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#10172