Skip to content

fix(server): store null instead of empty string for session deviceType and deviceOS#30048

Open
deveshkolte wants to merge 1 commit into
immich-app:mainfrom
deveshkolte:fix/28832-session-device-type-os-null
Open

fix(server): store null instead of empty string for session deviceType and deviceOS#30048
deveshkolte wants to merge 1 commit into
immich-app:mainfrom
deveshkolte:fix/28832-session-device-type-os-null

Conversation

@deveshkolte

Copy link
Copy Markdown

Description

When a session is created without device info, the database now stores
NULL instead of an empty string "" for deviceType and deviceOS columns.

Changes:

  • Zod schema: convert empty string input to null via .nullish() + .transform()
  • DB columns: nullable with default NULL; migration updates existing rows
  • Response schema: allows null to reflect actual stored value
  • TypeScript type: updated Session type to match

Fixes #28832 (session.deviceType and session.deviceOS columns)

How Has This Tested?

  • Existing test suite passes
  • Pattern follows the same approach as the already-merged person.name fix

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

None. I manually wrote the code following the established pattern from a previously merged PR for the same issue.

Comment on lines +38 to +41
@Column({ nullable: true, default: null })
deviceType!: string | null;

@Column({ default: '' })
deviceOS!: Generated<string>;
@Column({ nullable: true, default: null })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default: null is implicit, you don't need that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefer null values over empty strings

2 participants