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: Do not require detail field from App Store Connect API error #316

Merged
merged 4 commits into from
Mar 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-------------

21 changes: 14 additions & 7 deletions src/codemagic/apple/resources/error_response.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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:
@@ -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):
Original file line number Diff line number Diff line change
@@ -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: