Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make deprecated relations on App resource optional #439

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Nov 7, 2024

Occasionally App Store Connect list apps and read app information endpoints respond with payloads where included application resources are lacking preOrder relationship, which is currently declared as mandatory.

That causes App object initialization to fail:

File "/usr/local/lib/python3.11/site-packages/codemagic/cli/action.py", line 83, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/codemagic/tools/app_store_connect/action_groups/beta_groups_action_group.py", line 33, in add_build_to_beta_groups
    matched_beta_groups, matched_beta_group_names = self._get_beta_groups(build_id, beta_group_names)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/codemagic/tools/app_store_connect/action_groups/beta_groups_action_group.py", line 107, in _get_beta_groups
    app = self.api_client.builds.read_app(build_id)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/codemagic/apple/app_store_connect/builds/builds.py", line 96, in read_app
     return App(response["data"])
            ^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/codemagic/apple/resources/resource.py", line 253, in __init__
    self.relationships = self._create_relationships(api_response)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/codemagic/apple/resources/resource.py", line 245, in _create_relationships
    return cls.Relationships(**defined_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: App.Relationships.__init__() missing 1 required positional argument: 'preOrder'

Overcome this by making preOrder relationship optional.

It can also be seen that inAppPurchases relationship is marked as deprecated which means that it could be removed from response payloads in the future too. Mark that relationship as optional too for safety.

@priitlatt priitlatt added bug Something isn't working app-store-connect labels Nov 7, 2024
@priitlatt priitlatt marked this pull request as ready for review November 7, 2024 13:35
@priitlatt priitlatt merged commit 942b744 into master Nov 7, 2024
11 checks passed
@priitlatt priitlatt deleted the bugfix/deprecated-app-relations branch November 7, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app-store-connect bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants