-
-
Notifications
You must be signed in to change notification settings - Fork 3
fix(artifacts): Report distribution errors for unsupported and skipped builds (EME-422) #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
Changes from all commits
0754d48
b6ae542
815e7d4
5e24e6e
afa1aa7
3aa2762
56ddd6f
ec4a615
e32d4e7
cd781c4
d5b3c42
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 |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| from launchpad.artifacts.artifact_factory import ArtifactFactory | ||
| from launchpad.constants import ( | ||
| ArtifactType, | ||
| InstallableAppErrorCode, | ||
| PreprodFeature, | ||
| ProcessingErrorCode, | ||
| ProcessingErrorMessage, | ||
|
|
@@ -330,13 +331,24 @@ 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_error( | ||
| organization_id, artifact_id, InstallableAppErrorCode.SKIPPED, "invalid_signature" | ||
| ) | ||
| return | ||
| if apple_info.is_simulator: | ||
| logger.warning(f"BUILD_DISTRIBUTION skipped for {artifact_id}: simulator build") | ||
| self._update_distribution_error( | ||
| organization_id, artifact_id, InstallableAppErrorCode.SKIPPED, "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) | ||
|
|
@@ -354,9 +366,10 @@ 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 | ||
| # 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") | ||
| self._update_distribution_error( | ||
| organization_id, artifact_id, InstallableAppErrorCode.PROCESSING_ERROR, "unsupported artifact type" | ||
| ) | ||
|
|
||
| def _do_size( | ||
| self, | ||
|
|
@@ -438,6 +451,39 @@ def _update_artifact_error( | |
| else: | ||
| logger.info(f"Successfully updated artifact {artifact_id} with error information") | ||
|
|
||
| def _update_distribution_error( | ||
| self, | ||
| organization_id: str, | ||
| artifact_id: str, | ||
| error_code: InstallableAppErrorCode, | ||
| error_message: str, | ||
| ) -> None: | ||
| """Update distribution with error/skip information.""" | ||
| logger.info(f"Updating distribution for {artifact_id} with error code {error_code.value}") | ||
|
|
||
| self._statsd.increment( | ||
| "distribution.processing.error", | ||
| tags=[ | ||
| f"error_code:{error_code.value}", | ||
| f"error_message:{error_message}", | ||
| f"organization_id:{organization_id}", | ||
| ], | ||
| ) | ||
|
|
||
| try: | ||
| self._sentry_client.update_distribution( | ||
| org=organization_id, | ||
| artifact_id=artifact_id, | ||
| data={ | ||
| "error_code": error_code.value, | ||
| "error_message": error_message, | ||
| }, | ||
| ) | ||
| except SentryClientError: | ||
| logger.exception(f"Failed to update distribution error for artifact {artifact_id}") | ||
|
Comment on lines
+482
to
+483
Contributor
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. Bug: Network errors ( Suggested FixWiden the exception handler in Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| else: | ||
| logger.info(f"Successfully updated distribution for {artifact_id} with error information") | ||
|
|
||
| def _update_size_error_from_exception( | ||
| self, | ||
| organization_id: str, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.