Skip to content

Conversation

@ngc7293
Copy link
Contributor

@ngc7293 ngc7293 commented Mar 6, 2025

Description

The API currently does not respect the documentation when returning a person's birthDate. The doc/swagger says it will be of "YYYY-MM-DD" format but the string is a full ISO8601-with-tz string. This causes issue #16216 because the tag is strict about supported value formats.

I believe this was introduced by #15242 which switched some queries from TypeORM to Kysely for the person repository. TypeORM does not parse date, but our Kysely configuration does (explicitely).

This commits updates the types to represent both possibilities and ensure the API always returns the correct format.

Fixes #16216

How Has This Been Tested?

  • Ensured the following pages did not result errors
    • person/:id/ (for a person with an age)
    • photo/:id/ (for an asset with a face)
  • Ensured the birthdate could be read and edited

Screenshots (if appropriate)

Screenshot 2025-03-05 200300

API Changes

  • /person/:id/ now correctly returns birthDate as YYYY-MM-DD instead of full ISO8601-with-tz

Checklist:

  • 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)

@ngc7293 ngc7293 requested a review from danieldietzler as a code owner March 6, 2025 01:04
@ngc7293 ngc7293 force-pushed the david/fix-person-birthdate-return-type branch from 968fd25 to 3308d08 Compare March 6, 2025 01:05
Copy link
Contributor Author

@ngc7293 ngc7293 Mar 6, 2025

Choose a reason for hiding this comment

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

I edited this file manually. Whenever I tried to update it automatically, it would generate a large diff unrelated to my changes, some of which would cause compilation errors. Is this a known issue?

Copy link
Member

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

We want it to parse dates automatically I think. It's a feature we've enabled on purpose. We also already have type mappings (like this) in the config.repository.ts file. I think the fix should be specifically in the person.dto mapper function

@ngc7293
Copy link
Contributor Author

ngc7293 commented Mar 6, 2025

We want it to parse dates automatically I think. It's a feature we've enabled on purpose. We also already have type mappings (like this) in the config.repository.ts file. I think the fix should be specifically in the person.dto mapper function

How did I miss those... I was going crazy to trying to figure out why the e2e tests were failing. Thanks for the info, I'll amend my PR.

@ngc7293 ngc7293 force-pushed the david/fix-person-birthdate-return-type branch 3 times, most recently from 024b207 to 52294f1 Compare March 6, 2025 04:32
@ngc7293 ngc7293 changed the title fix(server): tell postgres.js not to parse dates fix(server): adjust type of person.birthDate Mar 6, 2025
@ngc7293 ngc7293 force-pushed the david/fix-person-birthdate-return-type branch 2 times, most recently from e119cfe to 7595b81 Compare March 6, 2025 04:43
@ngc7293 ngc7293 requested a review from jrasm91 March 6, 2025 04:50
hasNextPage?: boolean;
}

const asDateString = (x: string | Date | null) => (x instanceof Date ? x.toISOString().split('T')[0] : x);
Copy link
Member

Choose a reason for hiding this comment

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

Is this a dupe of the utils/date.ts below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, fixed

The API currently does not respect the documentation when returning a
person's birthDate. The doc/swagger says it will be of "YYYY-MM-DD"
format but the string is a full ISO8601-with-tz string. This causes
issue immich-app#16216 because the <input> tag is strict about supported value
formats.

I believe this was introduced by immich-app#15242 which switched some queries from
TypeORM to Kysely for the person repository. TypeORM does not parse
date, but our Kysely configuration does (explicitely).

This commits updates the types to represent both possibilities and ensure
the API always returns the correct format.
@ngc7293 ngc7293 force-pushed the david/fix-person-birthdate-return-type branch from 7595b81 to 2c33f19 Compare March 6, 2025 14:05
@alextran1502 alextran1502 merged commit 9870ad9 into immich-app:main Mar 10, 2025
42 of 43 checks passed
knechtandreas added a commit to knechtandreas/immich that referenced this pull request Mar 10, 2025
…s-broken

* main:
  fix(server): set the dev server restart policy of the dev server container to match the other containers (immich-app#16753)
  feat(web): remember search context (immich-app#16614)
  feat(server): read Android and Sony video camera make/model (immich-app#16678)
  fix(server): adjust type of person.birthDate (immich-app#16628)
  fix(web): add labels to memory lane buttons (immich-app#16664)
  feat(mobile): locate in timeline (immich-app#16722)
  chore(ml): uv (immich-app#16725)
  fix: 🍪 packages confusion (immich-app#16735)
  fix(web): Update people-card favorite position (immich-app#16746)
  chore(mobile): upgrade riverpod (immich-app#16742)
  chore(mobile): upgrade flutter_web_auth_2 (immich-app#16741)
  fix(docs): edge case when restoring dump that is unreadable as current user (immich-app#16758)
savely-krasovsky pushed a commit to savely-krasovsky/immich that referenced this pull request Jun 8, 2025
The API currently does not respect the documentation when returning a
person's birthDate. The doc/swagger says it will be of "YYYY-MM-DD"
format but the string is a full ISO8601-with-tz string. This causes
issue immich-app#16216 because the <input> tag is strict about supported value
formats.

I believe this was introduced by immich-app#15242 which switched some queries from
TypeORM to Kysely for the person repository. TypeORM does not parse
date, but our Kysely configuration does (explicitely).

This commits updates the types to represent both possibilities and ensure
the API always returns the correct format.
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.

[Bug] People: Birthdays are not showing

4 participants