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

Bugfix: google-play get-latest-build-number crashes on incomplete response #214

Merged
merged 7 commits into from
Apr 7, 2022

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Apr 7, 2022

This fixes #208.

Action google-play get-latest-build-number uses Google Play Developer API method edits.tracks.get to obtain the latest build build number in certain release track.
While API documentation indicates that the response for Track resource should contain a list of Release objects that all have reference to CountryTargeting which has a field called includeRestOfWorld, in reality the includeRestOfWorld field might not be defined. This will result in the following error on client side:

Traceback (most recent call last):
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 200, in invoke_cli
    CliApp._running_app._invoke_action(args)
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 156, in _invoke_action
    return cli_action(**action_args)
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 412, in wrapper
    return func(*args, **kwargs)
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/tools/google_play.py", line 143, in get_latest_build_number
    track = self.api_client.get_track_information(edit.id, track_name)
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/google_play/api_client.py", line 92, in get_track_information
    resource = Track(**track_response)
  File "<string>", line 5, in __init__
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/google_play/resources/track.py", line 74, in __post_init__
    self.releases = [Release(**release) for release in self.releases]
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/google_play/resources/track.py", line 74, in <listcomp>
    self.releases = [Release(**release) for release in self.releases]
  File "<string>", line 10, in __init__
  File "/home/docker/.local/lib/python3.8/site-packages/codemagic/google_play/resources/track.py", line 59, in __post_init__
    self.countryTargeting = CountryTargeting(**self.countryTargeting)
TypeError: __init__() missing 1 required positional argument: 'includeRestOfWorld'```

In order to tackle the cases when includeRestOfWorld is not defined, make it optional field for CountryTargeting resource and set default value for it to None.

Affected actions:

  • google-play get-latest-build-number.

@@ -28,7 +28,7 @@ class CountryTargeting(Resource):
"""

countries: List[str]
includeRestOfWorld: bool
includeRestOfWorld: Optional[bool] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the gist of the fix.

@priitlatt priitlatt added the bug Something isn't working label Apr 7, 2022
@priitlatt priitlatt marked this pull request as ready for review April 7, 2022 08:10
@priitlatt priitlatt merged commit ae8c7eb into master Apr 7, 2022
@priitlatt priitlatt deleted the bugfix/country-targeting-include-rest-of-world branch April 7, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant