Skip to content

fix(mobile): add missing backward-compat defaults in openapi_patching - #28755

Closed
timonrieger wants to merge 3 commits into
mainfrom
fix/pre-release-v3
Closed

fix(mobile): add missing backward-compat defaults in openapi_patching#28755
timonrieger wants to merge 3 commits into
mainfrom
fix/pre-release-v3

Conversation

@timonrieger

@timonrieger timonrieger commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Description

The

All three had their assertions patched out in the dart client, hiding the bugs. The regenerated dart client (from #27231) will (on merge) restore those assertions, causing debug-mode crashes.

Fixes # (issue)

How Has This Been Tested?

  • Test A
  • Test B

Screenshots (if appropriate)

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.

...

Comment on lines +55 to +58
if (value is Map) {
addDefault(value, 'prerelease', null);
}
break;

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.

I'm surprised this is needed, since it's nullable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

but not optional 😁

@timonrieger timonrieger Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it does not raise on main atm, due to this patch stripping assertions. While testing #27231, this raised tho in the mobile app

Logs

'package:openapi/model/server_version_response_dto.dart': Failed assertion: line 95 pos 16: 'json.containsKey(r'prerelease')': Required key "ServerVersionResponseDto[prerelease]" is missing from JSON.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

so effectively, prerelease is still required (see openapi spec) and thus needs this…unless we mark the field as optional, too

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.

We might need to fix other issues when we make that change. There are other required, nullable properties.

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.

Yeah so these aren't strictly required. Nullable values will fallback to null by default. Idk if need/want to add back in the required assertions.

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.

@timonrieger This might be an issue whenever a server promotes some field to required and the mobile app has to patch it. Rather than tracking this, maybe we should drop the assertions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i disagree. In debug/dev these assertions catch bugs which otherwise stay silent and could cascade further down if the response was used. i don't see why we would want to ignore these bugs, even if they don't affect us at the moment 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i mean it's basically response validation on the client-side (which we discussed server-side alr btw. #27901 😄 ). in prod build, these assertions get stripped anyways.

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.

I personally don't find any value in assertions for required null values. The only thing it actually does it make the mobile App break in development when testing against an old server.

@immich-push-o-matic

immich-push-o-matic Bot commented Jun 1, 2026

Copy link
Copy Markdown

📱 Android release APK (universal)d2ba1061f2dd33054512d3e99b9298b3186da407

Download: https://github.com/immich-app/immich/actions/runs/26786940279/artifacts/7345065820

QR code QR code

Installs as a separate app (applicationId app.alextran.immich.pr28755), so it coexists with the Play Store version and any other PR builds.

The dart generator can't express discriminated unions (see editing.dto.ts) properly, so the flattened class always has "missing" fields from the other variants.
@timonrieger
timonrieger force-pushed the fix/pre-release-v3 branch from 6d61b1d to d2ba106 Compare June 1, 2026 22:53
@timonrieger timonrieger changed the title fix(mobile): add backward-compat default for ServerVersionResponseDto.prerelease fix(mobile): add missing backward-compat defaults in openapi_patching Jun 1, 2026
@shenlong-tanwen

Copy link
Copy Markdown
Member

@timonrieger Do we still need this now that we removed the debug assertions?

@timonrieger

Copy link
Copy Markdown
Collaborator Author

Do we still need this now that we removed the debug assertions?

yes. i likely was not clear enough on the other PR, but I meant to say that I removed the patch that removed these assertions 😅 (clarified in #27231 (comment)). In the end it's up to you which path we go. I made my point above. If we keep these assertions removed (as they are now), we necessarily don't "need" this change here. As said, those are correctness fixes. Let me know what you prefer :)

@jrasm91

jrasm91 commented Jun 2, 2026

Copy link
Copy Markdown
Member

I would prefer keeping the patch that removes the assertions and not needing to add these type of patches.

@timonrieger

Copy link
Copy Markdown
Collaborator Author

as per team vote, we'll continue to suppress assertions. Thus closing this.

@timonrieger timonrieger closed this Jun 3, 2026
@timonrieger
timonrieger deleted the fix/pre-release-v3 branch June 3, 2026 10:04
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.

3 participants