Skip to content

Handle altool failures with returncode 0#478

Merged
priitlatt merged 6 commits intomasterfrom
bugfix/altool-zero-returncode-failures
Oct 17, 2025
Merged

Handle altool failures with returncode 0#478
priitlatt merged 6 commits intomasterfrom
bugfix/altool-zero-returncode-failures

Conversation

@priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Oct 16, 2025

The problem

This pull request addresses an issue where the app-store-connect publish command could incorrectly report a successful completion despite the App Store Connect publishing action failing.

A recent version of the altool (bundled with Xcode 26), exhibits unreliable behavior: it may return a successful exit code (0) even when the submission or publishing action has failed on the App Store Connect side. See also PR #476.

This behavior bypasses our existing error handling, leading to an issue where a successful publishing is reported although publishing actually had failed.

Fix

To improve error reporting this PR implements a new error detection mechanism:

  • We no longer rely solely on the altool return code.
  • Publishing status is now determined by parsing the command output for specific failure indicators and result structures.

The changes proposed here include crucial updates to handle output from recent altool versions:

  • The logic for detecting the final result has been revised to match the latest formatting changes introduced in recent altool versions.
  • We now correctly detect and process the result JSON structure even when it spans multiple lines in the command output.

Updated actions

  • app-store-connect publish

@priitlatt priitlatt marked this pull request as ready for review October 16, 2025 12:23
@priitlatt priitlatt requested a review from fran-tirapu October 16, 2025 13:53
Find the last JSON from given STDOUT which matches Altool result schema
"""

json_patt = re.compile(r"^\s*\{.*\}\s*$", re.MULTILINE | re.DOTALL)
Copy link
Contributor

@fran-tirapu fran-tirapu Oct 17, 2025

Choose a reason for hiding this comment

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

I am not sure about the need of this regex.
It seems like json.loads and AltoolResult.create are enough validation. do you add it just as a quick check to improve performance or are there any hidden thing I am not seeing?

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 a good point. json.loads will do validation on its own anyway, rendering the regex check useless.
And running some benchmarks revealed that with "good" cases where the JSON result is right in the end of the log there is no speedup, however in case of a big enough log (~2000 lines) which contains no valid result, then there is a slowdown when using regex check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 52a9ec4.

Copy link
Contributor

@fran-tirapu fran-tirapu left a comment

Choose a reason for hiding this comment

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

🚀
Nice job adding mocks to test all possible scenarios with legacy and current versions of the tool.

@priitlatt priitlatt merged commit b353d72 into master Oct 17, 2025
13 checks passed
@priitlatt priitlatt deleted the bugfix/altool-zero-returncode-failures branch October 17, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants