fix(mobile): narrow closed-train states and degrade gracefully on API error

Review follow-ups:
- Drop IN_REVIEW / WAITING_FOR_REVIEW / PROCESSING_FOR_APP_STORE from the
  closed set. Those versions still accept TestFlight builds, so treating them
  as closed would auto-bump the marketing version mid-beta-iteration — the
  exact workflow this change is meant to preserve. Only approved/released/
  removed states terminally close the train (the 90186 case).
- Rescue API errors in version_train_closed? and assume open, so a transient
  ASC blip degrades to today's behavior instead of failing the release.

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
brennanb2025
2026-06-28 11:31:44 -07:00
co-authored by Orca
parent 603a86fd40
commit f2d4d32bd0
+10 -8
View File
@@ -30,18 +30,15 @@ BUNDLE_ID = "com.stably.orca.mobile"
TESTFLIGHT_GROUPS = ["peeps"].freeze
DEFAULT_TESTFLIGHT_CHANGELOG = "Latest Orca Mobile updates and fixes.".freeze
# App Store version states in which the version "train" no longer accepts new
# TestFlight build uploads (altool rejects with 90186 "train ... is closed").
# Once a version has been submitted/approved/released, builds must go under a
# higher marketing version. PROCESSING_FOR_APP_STORE / IN_REVIEW are included
# conservatively: a build is already committed to that train.
# App Store version states in which the version "train" is terminally closed to
# new TestFlight build uploads (altool rejects with 90186 "train ... is
# closed"). Only approved/released/removed states qualify: a version that is
# merely IN_REVIEW / WAITING_FOR_REVIEW / PROCESSING_FOR_APP_STORE still accepts
# TestFlight builds, so bumping on those would break normal beta iteration.
CLOSED_APP_STORE_STATES = %w[
READY_FOR_SALE
PENDING_DEVELOPER_RELEASE
PENDING_APPLE_RELEASE
PROCESSING_FOR_APP_STORE
IN_REVIEW
WAITING_FOR_REVIEW
REPLACED_WITH_NEW_VERSION
REMOVED_FROM_SALE
DEVELOPER_REMOVED_FROM_SALE
@@ -91,6 +88,8 @@ end
# Returns true when `version`'s App Store train is closed to new build uploads.
# app_store_connect_api_key (set_spaceship_token: true, the default) has already
# authenticated Spaceship::ConnectAPI globally, so no extra auth is needed here.
# On any API error, degrade to "open": the upload then either succeeds or fails
# with the same 90186 we have always seen — never worse than today's behavior.
def version_train_closed?(version)
app = Spaceship::ConnectAPI::App.find(BUNDLE_ID)
return false unless app
@@ -98,6 +97,9 @@ def version_train_closed?(version)
app
.get_app_store_versions(filter: { versionString: version })
.any? { |app_store_version| CLOSED_APP_STORE_STATES.include?(app_store_version.app_store_state) }
rescue StandardError => error
UI.important("Could not determine App Store state for #{version} (#{error.message}); assuming open.")
false
end
def testflight_changelog