-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix(artifacts): Report error for unknown artifact types in distribution #567
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
base: main
Are you sure you want to change the base?
Changes from all commits
a4254dc
49aa2b5
e003ab1
fe8817e
e84e225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| from launchpad.artifacts.artifact_factory import ArtifactFactory | ||
| from launchpad.constants import ( | ||
| ArtifactType, | ||
| InstallableAppErrorCode, | ||
| PreprodFeature, | ||
| ProcessingErrorCode, | ||
| ProcessingErrorMessage, | ||
|
|
@@ -302,13 +303,20 @@ def _do_distribution( | |
| logger.info(f"BUILD_DISTRIBUTION for {artifact_id} (project: {project_id}, org: {organization_id})") | ||
| if isinstance(artifact, ZippedXCArchive): | ||
| apple_info = cast(AppleAppInfo, info) | ||
| if apple_info.is_code_signature_valid and not apple_info.is_simulator: | ||
| with tempfile.TemporaryDirectory() as temp_dir_str: | ||
| temp_dir = Path(temp_dir_str) | ||
| ipa_path = temp_dir / "App.ipa" | ||
| artifact.generate_ipa(ipa_path) | ||
| with open(ipa_path, "rb") as f: | ||
| self._sentry_client.upload_installable_app(organization_id, project_id, artifact_id, f) | ||
| if not apple_info.is_code_signature_valid: | ||
| logger.warning(f"BUILD_DISTRIBUTION skipped for {artifact_id}: invalid code signature") | ||
| self._update_distribution_skip(organization_id, project_id, artifact_id, "invalid_signature") | ||
| return | ||
| if apple_info.is_simulator: | ||
| logger.warning(f"BUILD_DISTRIBUTION skipped for {artifact_id}: simulator build") | ||
| self._update_distribution_skip(organization_id, project_id, artifact_id, "simulator") | ||
| return | ||
| with tempfile.TemporaryDirectory() as temp_dir_str: | ||
| temp_dir = Path(temp_dir_str) | ||
| ipa_path = temp_dir / "App.ipa" | ||
| artifact.generate_ipa(ipa_path) | ||
| with open(ipa_path, "rb") as f: | ||
| self._sentry_client.upload_installable_app(organization_id, project_id, artifact_id, f) | ||
| elif isinstance(artifact, (AAB, ZippedAAB)): | ||
| with tempfile.TemporaryDirectory() as temp_dir_str: | ||
| temp_dir = Path(temp_dir_str) | ||
|
|
@@ -326,9 +334,16 @@ def _do_distribution( | |
| with apk.raw_file() as f: | ||
| self._sentry_client.upload_installable_app(organization_id, project_id, artifact_id, f) | ||
| else: | ||
| # TODO(EME-422): Should call _update_artifact_error here once we | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # support setting errors just for build. | ||
| logger.error(f"BUILD_DISTRIBUTION failed for {artifact_id} (project: {project_id}, org: {organization_id})") | ||
| logger.error(f"BUILD_DISTRIBUTION failed for {artifact_id}: unsupported artifact type") | ||
| try: | ||
| self._sentry_client.update_distribution_error( | ||
| org=organization_id, | ||
| artifact_id=artifact_id, | ||
| error_code=InstallableAppErrorCode.PROCESSING_ERROR.value, | ||
| error_message="unsupported artifact type", | ||
| ) | ||
| except SentryClientError: | ||
| logger.exception(f"Failed to update distribution error for artifact {artifact_id}") | ||
|
|
||
| def _do_size( | ||
| self, | ||
|
|
@@ -410,6 +425,24 @@ def _update_artifact_error( | |
| else: | ||
| logger.info(f"Successfully updated artifact {artifact_id} with error information") | ||
|
|
||
| def _update_distribution_skip( | ||
| self, | ||
| organization_id: str, | ||
| project_id: str, | ||
| artifact_id: str, | ||
| skip_reason: str, | ||
| ) -> None: | ||
| """Report distribution skip via the dedicated distribution endpoint.""" | ||
| try: | ||
| self._sentry_client.update_distribution_error( | ||
| org=organization_id, | ||
| artifact_id=artifact_id, | ||
| error_code=InstallableAppErrorCode.SKIPPED.value, | ||
| error_message=skip_reason, | ||
| ) | ||
| except SentryClientError: | ||
| logger.exception(f"Failed to update distribution skip for artifact {artifact_id}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Narrow exception catch turns silent skips into processing failuresMedium Severity Both Additional Locations (1) |
||
|
|
||
| def _update_size_error_from_exception( | ||
| self, | ||
| organization_id: str, | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cursorbot said that if a
ZippedXCArchivehas an invalid code signature or simulator build, it silently does nothing so this addresses that.