[GH-ISSUE #763] beta-build-localizations create: expose existing upsert logic as --upsert flag #205

Closed
opened 2026-02-26 21:34:00 +03:00 by kerem · 0 comments
Owner

Originally created by @mithileshchellappan on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/rudrankriyam/App-Store-Connect-CLI/issues/763

Summary

Expose the existing UpsertBetaBuildLocalization() logic as a --upsert flag on beta-build-localizations create, so agents don't need to handle create-vs-update branching themselves.

Problem

asc beta-build-localizations create fails when a localization for the given locale already exists on a build:

Error: beta-build-localizations create: failed to create: The provided entity includes 
an attribute with an invalid value: There is an entity with same 'locale'.

This forces agents into a two-step pattern:

# Try create, if it fails, list and update
asc beta-build-localizations create --build BUILD_ID --locale en-US --whats-new "notes"
# ^ fails if en-US already exists

# Fallback: list to find the ID, then update
asc beta-build-localizations list --build BUILD_ID  # find the locale ID
asc beta-build-localizations update --id LOC_ID --whats-new "notes"

Existing Internal Solution

The codebase already has a clean upsert function in `internal/cli/shared/test_notes.go`:

func UpsertBetaBuildLocalization(client *asc.Client, buildID, locale, whatsNew string) error {
    // Lists existing localizations for the build
    // If locale exists → updates it
    // If locale doesn't exist → creates it
}

This is already used by:

  • `publish testflight` (publish.go:167)
  • `builds upload` (builds_commands.go:352)

It just isn't exposed to the standalone `beta-build-localizations create` command.

Proposal

Add a `--upsert` flag to `beta-build-localizations create`:

# Idempotent — creates if missing, updates if exists
asc beta-build-localizations create \
  --build BUILD_ID \
  --locale en-US \
  --whats-new "Test notes" \
  --upsert

Implementation

In `internal/cli/betabuildlocalizations/beta_build_localizations.go`, the `create` handler (around line 219) should:

  1. Check for `--upsert` flag
  2. If set, call `shared.UpsertBetaBuildLocalization()` instead of `client.CreateBetaBuildLocalization()`
  3. If not set, preserve current behavior (fail on duplicate)

This is a minimal change since the upsert logic already exists and is tested through other code paths.

Acceptance Criteria

  • `asc beta-build-localizations create --upsert --build BUILD_ID --locale en-US --whats-new "notes"` succeeds whether or not en-US already exists
  • Without `--upsert`, current behavior is preserved (fails on duplicate locale)
  • Tests pass with `ASC_BYPASS_KEYCHAIN=1`
Originally created by @mithileshchellappan on GitHub (Feb 24, 2026). Original GitHub issue: https://github.com/rudrankriyam/App-Store-Connect-CLI/issues/763 ## Summary Expose the existing `UpsertBetaBuildLocalization()` logic as a `--upsert` flag on `beta-build-localizations create`, so agents don't need to handle create-vs-update branching themselves. ## Problem `asc beta-build-localizations create` fails when a localization for the given locale already exists on a build: ``` Error: beta-build-localizations create: failed to create: The provided entity includes an attribute with an invalid value: There is an entity with same 'locale'. ``` This forces agents into a two-step pattern: ```bash # Try create, if it fails, list and update asc beta-build-localizations create --build BUILD_ID --locale en-US --whats-new "notes" # ^ fails if en-US already exists # Fallback: list to find the ID, then update asc beta-build-localizations list --build BUILD_ID # find the locale ID asc beta-build-localizations update --id LOC_ID --whats-new "notes" ``` ## Existing Internal Solution The codebase already has a clean upsert function in \`internal/cli/shared/test_notes.go\`: ```go func UpsertBetaBuildLocalization(client *asc.Client, buildID, locale, whatsNew string) error { // Lists existing localizations for the build // If locale exists → updates it // If locale doesn't exist → creates it } ``` This is already used by: - \`publish testflight\` (publish.go:167) - \`builds upload\` (builds_commands.go:352) It just isn't exposed to the standalone \`beta-build-localizations create\` command. ## Proposal Add a \`--upsert\` flag to \`beta-build-localizations create\`: ```bash # Idempotent — creates if missing, updates if exists asc beta-build-localizations create \ --build BUILD_ID \ --locale en-US \ --whats-new "Test notes" \ --upsert ``` ### Implementation In \`internal/cli/betabuildlocalizations/beta_build_localizations.go\`, the \`create\` handler (around line 219) should: 1. Check for \`--upsert\` flag 2. If set, call \`shared.UpsertBetaBuildLocalization()\` instead of \`client.CreateBetaBuildLocalization()\` 3. If not set, preserve current behavior (fail on duplicate) This is a minimal change since the upsert logic already exists and is tested through other code paths. ## Acceptance Criteria - \`asc beta-build-localizations create --upsert --build BUILD_ID --locale en-US --whats-new "notes"\` succeeds whether or not en-US already exists - Without \`--upsert\`, current behavior is preserved (fails on duplicate locale) - Tests pass with \`ASC_BYPASS_KEYCHAIN=1\`
kerem closed this issue 2026-02-26 21:34:00 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/App-Store-Connect-CLI#205
No description provided.