Skip to content

Commit

Permalink
Bugfix: Do not require detail field from App Store Connect API error (
Browse files Browse the repository at this point in the history
#316)

* Do not require 'detail' field from App Store Connect API error

* Update version and fill in changelog

* Fix changelog
  • Loading branch information
priitlatt authored Mar 24, 2023
1 parent f297e9c commit a6ce797
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
hooks:
- id: add-trailing-comma
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: [--check-only]
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Version 0.39.2
**Features**
- Improve Python API for module `codemagic.tools.keychain`. Allow passing passwords as strings in addition to `codemagic.tools.keychain.Password` for `Keychain` methods. [PR #315](https://github.com/codemagic-ci-cd/cli-tools/pull/315)

**Bugfixes**
- Do not require `detail` attribute from App Store Connect API error responses. [PR #316](https://github.com/codemagic-ci-cd/cli-tools/pull/316)

Version 0.39.1
-------------

Expand Down
21 changes: 14 additions & 7 deletions src/codemagic/apple/resources/error_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Error(DictSerializable):
code: str
status: str
title: str
detail: str
detail: Optional[str] = None
id: Optional[str] = None
source: Optional[Dict[str, str]] = None
meta: Optional[ErrorMeta] = None
Expand All @@ -49,7 +49,11 @@ def __post_init__(self):
self.meta = ErrorMeta(**self.meta)

def __str__(self):
s = f'{self.title} - {self.detail}'
if self.detail is None:
s = self.title
else:
s = f'{self.title} - {self.detail}'

if self.meta:
meta = textwrap.indent(str(self.meta), '\t')
if meta:
Expand All @@ -66,11 +70,14 @@ def __init__(self, api_response: Dict):
@classmethod
def from_raw_response(cls, response: Response) -> ErrorResponse:
error_response = ErrorResponse({'errors': []})
error_response.errors.append(Error(
code='NA',
status=str(response.status_code),
title='Request failed',
detail=f'Request failed with status code {response.status_code}'))
error_response.errors.append(
Error(
code='NA',
status=str(response.status_code),
title='Request failed',
detail=f'Request failed with status code {response.status_code}',
),
)
return error_response

def __str__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ def _create_review_submission(self, app: App, platform: Platform) -> ReviewSubmi
existing_submission_matches: Iterator[Optional[re.Match]] = (
existing_submission_error_patt.search(error.detail)
for error in api_error.error_response.errors
if error.detail is not None
)

try:
Expand Down

0 comments on commit a6ce797

Please sign in to comment.