adobe / adobe/spacecat-api-service

Prevent GL from being stored as a brand region

Open
#3,168 1 comment 0 reactions 1 assignee Claimed by @rainer-friederich View on GitHub
Dominant language
JavaScript
Stars
10
Forks
15
Avg merge
1d 9h
Merged PRs (30d)
150

Description

## Problem

SpaceCat currently has write paths that default a missing LLMO brand region to `gl`. `GL` is the ISO country code for Greenland and must not be used as a fallback or global-market marker. When no valid market is available, the stored brand region must be `US`.

The current onboarding implementation explicitly seeds this value in `src/controllers/llmo/llmo-onboarding.js`:

```js
export function onboardingStubRegions(region) {
return region ? [region] : ['gl'];
}
```

`src/support/customer-config-mapper.js` also contains several `['gl']` fallbacks for brand, alias, competitor, and prompt regions. Any fallback that can reach persisted customer or brand configuration can create the same invalid state.

## Production impact

A Costa Cruises onboarding stored `GL` on the SpaceCat brand record for site `01a05cf5-1482-7c80-831d-c34800cbe4c4`. DRS subsequently interpreted it as Greenland, asked for clarification about Danish and Greenlandic prompts, parsed zero prompts, and permanently failed job `01893354-eae6-4bcc-beda-438434fd0ee7`.

The downstream defensive change is tracked separately:

https://github.com/adobe-rnd/llmo-data-retrieval-service/issues/3103

## Required behavior

SpaceCat must never persist `GL` as an LLMO brand region. A missing region or a legacy `GL` value must be normalized to `US` at the write boundary before brand configuration is stored. Matching should be case-insensitive and ignore surrounding whitespace.

## Acceptance criteria

- LLMO onboarding defaults an omitted region to `US`, not `GL`.
- Explicit `GL` values are normalized to `US` before brand configuration is persisted.
- All hard-coded `gl` fallbacks in customer-config mapping and onboarding are audited; fallbacks representing a missing/global market use `US`.
- Brand create, update, onboarding-stub, and customer-config migration paths cannot persist `GL`.
- Existing brand records containing `GL` as the legacy global fallback are migrated to `US`, including the affected Costa Cruises record.
- Other valid ISO region values remain unchanged.
- Automated coverage verifies omitted, lowercase `gl`, uppercase `GL`, whitespace-padded, and non-`GL` values across the affected write paths.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.