codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
267 stars 42 forks source link

`app-store-connect apps builds <id>` fails with unexpected keyword argument 'lsMinimumSystemVersion' #151

Closed pyrtsa closed 3 years ago

pyrtsa commented 3 years ago

When running app-store-connect apps builds <id> today with an iOS-only app we own, the tool fails with an error message like:

Executing AppStoreConnect action apps failed unexpectedly. Detailed logs are available at "/var/folders/path/to/codemagic-13-09-21.log". To see more details about the error, add `--verbose` command line option.

and the log file ends with the Python stack trace:

[14:31:36 13-09-2021] ERROR cli_app.py:113 > Exception traceback:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/codemagic/cli/cli_app.py", line 202, in invoke_cli
    CliApp._running_app._invoke_action(args)
  File "/usr/local/lib/python3.9/site-packages/codemagic/cli/cli_app.py", line 156, in _invoke_action
    return cli_action(**action_args)
  File "/usr/local/lib/python3.9/site-packages/codemagic/cli/cli_app.py", line 455, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/codemagic/tools/_app_store_connect/action_groups/apps_action_group.py", line 72, in list_app_builds
    return self._list_related_resources(
  File "/usr/local/lib/python3.9/site-packages/codemagic/tools/_app_store_connect/resource_manager_mixin.py", line 80, in _list_related_resources
    resources = list_related_resources_method(resource_id, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/codemagic/apple/app_store_connect/apps/apps.py", line 81, in list_builds
    return [Build(build) for build in self.client.paginate(url, page_size=None)]
  File "/usr/local/lib/python3.9/site-packages/codemagic/apple/app_store_connect/apps/apps.py", line 81, in <listcomp>
    return [Build(build) for build in self.client.paginate(url, page_size=None)]
  File "/usr/local/lib/python3.9/site-packages/codemagic/apple/resources/resource.py", line 196, in __init__
    self.attributes = self._create_attributes(api_response)
  File "/usr/local/lib/python3.9/site-packages/codemagic/apple/resources/resource.py", line 178, in _create_attributes
    return cls.Attributes(**api_response['attributes'])
TypeError: __init__() got an unexpected keyword argument 'lsMinimumSystemVersion'

preceded by a JSON dump where every JSON object under $.data[].attributes contains the key lsMinimumSystemVersion with a value of null (i.e. None). (I think this might be a new key Apple have introduced related to TestFlight support for macOS.)

Regardless, I think the tool shouldn't blindly pass **kwargs from remote JSON data, or else at least tolerate previously unknown keys in the parsing.

pyrtsa commented 3 years ago

The parser seems to lack handling for these three new keys in attributes:

priitlatt commented 3 years ago

@pyrtsa, thank you for a detailed issue description. We'll look into it soon.

priitlatt commented 3 years ago

@pyrtsa, could you please check what version of tools do you have installed? It can be done calling

> app-store-connect --version

Actually handing for undefined attributes was fixed in version 0.9.5 already, and as such, with latest revision the command should not fail unexpectedly with an error. Instead the undefined fields are logged into the logfile as

WARNING - Unknown field 'lsMinimumSystemVersion' for resource Build.Attributes

That being said though, we aim to have acurate model descriptions matching the objects returned by Apple's API. So the values still need to be described on our side in the code.

pyrtsa commented 3 years ago

Oh, I was on 0.9.4.

You're quite right that 0.9.5 fixes the very issue. Closing this issue, thank you!