fix(mobile): add missing backward-compat defaults in openapi_patching - #28755
fix(mobile): add missing backward-compat defaults in openapi_patching#28755timonrieger wants to merge 3 commits into
Conversation
| if (value is Map) { | ||
| addDefault(value, 'prerelease', null); | ||
| } | ||
| break; |
There was a problem hiding this comment.
I'm surprised this is needed, since it's nullable.
There was a problem hiding this comment.
but not optional 😁
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
so effectively, prerelease is still required (see openapi spec) and thus needs this…unless we mark the field as optional, too
There was a problem hiding this comment.
We might need to fix other issues when we make that change. There are other required, nullable properties.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
📱 Android release APK (universal) — Download: https://github.com/immich-app/immich/actions/runs/26786940279/artifacts/7345065820 Installs as a separate app (applicationId |
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.
6d61b1d to
d2ba106
Compare
|
@timonrieger 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 :) |
|
I would prefer keeping the patch that removes the assertions and not needing to add these type of patches. |
|
as per team vote, we'll continue to suppress assertions. Thus closing this. |
Description
The
prereleasefield was added toServerVersionResponseDtoin feat: release candidate support #28665createdAtwas added toSyncAssetV1/SyncAssetV2in feat: recently added assets page #28272AssetEditActionItemDtoParametershas always had a union type mismatch since feat: image editing #24155All 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?
Screenshots (if appropriate)
Checklist:
src/services/uses repositories implementations for database calls, filesystem operations, etc.src/repositories/is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services/)Please describe to which degree, if any, an LLM was used in creating this pull request.
...