Skip to content

fix: Update sdk version locales - #3205

Merged
hellofanny merged 2 commits into
feat/multilanguagefrom
fix/update-sdk-version-locales
Feb 10, 2026
Merged

hellofanny merged 2 commits into
feat/multilanguagefrom
fix/update-sdk-version-locales

Conversation

@hellofanny

@hellofanny hellofanny commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Updates the faststore-sdk version to the latest with isDefault locale fix.
It might have been cause some inconsistencies in our testing.

How it works?

We should have only one isDefault: true per binding.

Before After
image image

How to test it?

  1. Run the store locale.
  2. run node packages/cli/bin/run.js generate-i18n ./packages/core
  3. check the locales setting in discovery.config. For each binding, you should see only one isDefault:true.

Starters Deploy Preview

starter preview: https://brandless-cma5xay4001f6dn4xjwato8b4-hk7s7lz52.b.vtex.app/

References

Summary by CodeRabbit

  • New Features

    • Enhanced locale and currency binding resolution with improved default binding selection for better multi-locale support.
  • Chores

    • Updated SDK dependencies for improved stability.

@hellofanny
hellofanny requested a review from a team as a code owner February 10, 2026 02:49
@hellofanny
hellofanny requested review from lariciamota and ommeirelles and removed request for a team February 10, 2026 02:49
@hellofanny hellofanny self-assigned this Feb 10, 2026
@coderabbitai

coderabbitai Bot commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes include a dependency version bump for @vtex/faststore-sdk and a new boolean property isDefault added to the Binding interface in localization types, which provides metadata for binding resolution preferences.

Changes

Cohort / File(s) Summary
Dependency Updates
packages/cli/package.json
Updated @vtex/faststore-sdk from 0.1.1-canary.1 to 0.1.1-canary.3.
Type Extensions
packages/core/src/sdk/localization/types.ts
Added isDefault: boolean property to Binding interface for locale/currency binding resolution preference metadata.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • lariciamota
  • lucasfp13

Poem

📦 A canary hops from one to three,
Types grow wiser, isDefault to see,
Bindings now prefer with grace,
Small tweaks in the right place! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title refers to a real aspect of the changes (SDK version update) but doesn't capture the main point: adding isDefault support to the Binding interface for proper locale/currency resolution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/update-sdk-version-locales

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@hellofanny hellofanny changed the title Fix: Update sdk version locales fix: Update sdk version locales Feb 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/core/src/sdk/localization/types.ts`:
- Around line 5-14: The JSDoc on isDefault currently claims "exactly one per
locale" but that constraint isn't enforced; update the comment in
packages/core/src/sdk/localization/types.ts to document the actual runtime
fallback (i.e., when no binding has isDefault the code uses find((b) =>
b.isDefault) ?? matches[0]) and state that generate-i18n/SDK will fall back to
the first match rather than enforcing a single default; alternatively, if you
prefer enforcement, add a validation step in generate-i18n that checks bindings
per locale and emits a warning/error when zero or multiple isDefault=true are
found (reference generate-i18n and the runtime selection logic using find((b) =>
b.isDefault) ?? matches[0] when implementing the check).

Comment on lines +5 to 14
/**
* When true, this binding is preferred for its locale in two cases:
* (1) When the URL does not match any binding, the default locale's binding
* with isDefault is used for session/settings.
* (2) When resolving locale+currency and multiple bindings match (e.g. same
* currency, different URLs), the one with isDefault is chosen.
* Each locale should have exactly one binding with isDefault: true to avoid
* ambiguous resolution.
*/
isDefault: boolean

@coderabbitai coderabbitai Bot Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Search for isDefault usage and any validation logic
rg -n 'isDefault' --type ts -g '!**/node_modules/**' -g '!**/*.d.ts' | head -50

Repository: vtex/faststore

Length of output: 4921


🏁 Script executed:

# Search for validation logic related to bindings or locales
rg -n -A 5 'validate|check.*binding|default.*per.*locale' --type ts -g '!**/node_modules/**' -g '!**/*.d.ts' | head -80

Repository: vtex/faststore

Length of output: 7358


🏁 Script executed:

# Look for generate-i18n command or similar CLI generation logic
fd -e ts -g '!**/node_modules/**' | xargs grep -l 'generate.*i18n\|generate.*localization' 2>/dev/null

Repository: vtex/faststore

Length of output: 42


🏁 Script executed:

# Search for generate-i18n in all files
rg -n 'generate-i18n' --type ts --type js -g '!**/node_modules/**'

Repository: vtex/faststore

Length of output: 724


🏁 Script executed:

# Check for any validation/enforcement of binding constraints
rg -n 'exactly one|one.*default|constraint.*binding|each locale' --type ts -g '!**/node_modules/**'

Repository: vtex/faststore

Length of output: 557


🏁 Script executed:

# Look at the CLI package structure for i18n generation
find packages/cli -name '*i18n*' -o -name '*locali*' 2>/dev/null | head -20

Repository: vtex/faststore

Length of output: 148


🏁 Script executed:

# Check bindingSelector.test.ts to understand the fallback behavior
sed -n '168,180p' packages/core/test/sdk/localization/bindingSelector.test.ts

Repository: vtex/faststore

Length of output: 534


🏁 Script executed:

# Read the generate-i18n.ts file to see what validation it performs
cat packages/cli/src/commands/generate-i18n.ts

Repository: vtex/faststore

Length of output: 4181


🏁 Script executed:

# Also check the test file to understand expected behavior
cat packages/cli/src/commands/generate-i18n.test.ts

Repository: vtex/faststore

Length of output: 7562


The "exactly one per locale" constraint is not validated — update JSDoc or add runtime checks.

No validation exists in generate-i18n or the SDK to enforce this constraint. The test data itself includes violations (e.g., it-IT, en-CA have no isDefault: true binding). The code handles missing defaults gracefully via fallbacks (find((b) => b.isDefault) ?? matches[0]), but the JSDoc claims a constraint that isn't actually enforced. Either:

  1. Add validation in generate-i18n to warn/error on constraint violations, or
  2. Update the JSDoc to document the actual fallback behavior instead of prescribing an unenforceable rule.
🤖 Prompt for AI Agents
In `@packages/core/src/sdk/localization/types.ts` around lines 5 - 14, The JSDoc
on isDefault currently claims "exactly one per locale" but that constraint isn't
enforced; update the comment in packages/core/src/sdk/localization/types.ts to
document the actual runtime fallback (i.e., when no binding has isDefault the
code uses find((b) => b.isDefault) ?? matches[0]) and state that
generate-i18n/SDK will fall back to the first match rather than enforcing a
single default; alternatively, if you prefer enforcement, add a validation step
in generate-i18n that checks bindings per locale and emits a warning/error when
zero or multiple isDefault=true are found (reference generate-i18n and the
runtime selection logic using find((b) => b.isDefault) ?? matches[0] when
implementing the check).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is already being validated in the sdk, so I didn't add any extra test for it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for imports from `@vtex/faststore-sdk` and any validation-related code
echo "=== Searching for SDK imports and usage ==="
rg -n '@vtex/faststore-sdk' --type ts -A 5 | head -100

echo -e "\n=== Searching for binding validation or locale validation calls ==="
rg -n 'validate.*binding|validate.*locale|validateBinding|validateLocale' --type ts -C 3 | head -80

echo -e "\n=== Check if SDK exports validation functions ==="
rg -n 'from.*@vtex/faststore-sdk.*import' --type ts | head -30

Length of output: 5825


🏁 Script executed:

#!/bin/bash
# Check how FastStoreSDK is used in generate-i18n command
echo "=== FastStoreSDK usage in generate-i18n.ts ==="
sed -n '1,120p' packages/cli/src/commands/generate-i18n.ts | grep -A 10 -B 2 'FastStoreSDK\|sdk\.'

Length of output: 600


@hellofanny Got it — I can't inspect the external SDK's validation logic from this repo, so I'll defer to your knowledge of the SDK implementation. Thanks for clarifying!


🧬 Code Graph Analysis Results
  • File: packages/core/src/sdk/localization/index.ts, lines 1-1

    • Snippet:
      Binding
  • File: packages/core/src/sdk/localization/index.ts, lines 1-1

    • Snippet:
      Locale
  • File: packages/core/src/sdk/localization/index.ts, lines 1-1

    • Snippet:
      BindingSelectorError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could update the test data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@hellofanny
hellofanny merged commit 1beb0ab into feat/multilanguage Feb 10, 2026
4 of 5 checks passed
@hellofanny
hellofanny deleted the fix/update-sdk-version-locales branch February 10, 2026 14:53
lemagnetic added a commit that referenced this pull request Mar 5, 2026
## What's the purpose of this pull request?

Removing hardcoded labels:
- #3099
- #3102 
- #3107 
- #3104 
- #3103 
- #3125
- #3131
- #3116
- #3142
- #3192

Setting Up locales
- #3141
- #3143
- #3147
- #3156
- #3162
- #3145
- #3164
- #3169
- #3171
- #3176
- #3180
- #3169
 custom path
- #3185
- #3162
- #3156
- #3170

Components
- #3093
- #3175

Fetching content 

- #3165

Others
- #3176
- #3171
- #3181
- #3189
- #3205


## How to test locally?
- Run `pnpm I` (install all the new dependencies and needed packages)
- If you want to try localization feature, go
to`/discovery.config.default.js`:
Enable localization:
```
localization: {
  enabled: true
}
```
- Run `node packages/cli/bin/run.js generate-i18n ./packages/core` to
fetch the bindings

If the contentSource is not set to content platform yet, you will see a
message to update to it.
>   contentSource: {
>     type: 'CP',
>   },

⚠️ Note: Ensure the url is set to localhost for local testing. These
locale bindings are generated in `discovery.config` after running the
generate-i18n command.

```diff
localization: {
  enabled: true,
  defaultLocale: 'en-US',
   regions: {...},
    locales: {
      'pt-BR': {
           ...
        bindings: [
          {
            currencyCode: 'BRL',
-           url: 'https://brandless.fast.store/pt-BR',
+           url: 'http://localhost:3000/pt-BR',
            salesChannel: '2',
            isDefault: true,
            locales: [
              {
                code: 'pt-BR',
                isDefault: true,
              },
            ],
          },
        ],
      },
      'it-IT': {
        ...
        bindings: [
          {
            currencyCode: 'EUR',
-           url: 'https://brandless.fast.store/it-IT',
+           url: 'http://localhost:3000/it-IT',
            salesChannel: '3',
            isDefault: true,
            locales: [
              {
                code: 'it-IT',
                isDefault: true,
              },
            ],
          },
          {
            currencyCode: 'EUR',
-           url: 'https://brandless.fast.store/europe/it',
+           url: 'http://localhost:3000/europe/it',
            salesChannel: '3',
            isDefault: false,
            locales: [
              {
                code: 'it-IT',
                isDefault: true,
              },
            ],
          },
        ],
      },
      'en-US': {
        code: 'en-US',
        name: 'English',
        languageCode: 'en',
        languageName: 'English',
        script: 'Latn',
        textDirection: 'ltr',
        regionCode: 'US',
        bindings: [
          {
            currencyCode: 'USD',
-           url: 'https://brandless.fast.store',
+           url: 'http://localhost:3000,
            salesChannel: '1',
            isDefault: true,
            locales: [
              {
                code: 'en-US',
                isDefault: true,
              },
            ],
          },
        ],
      },
    ...
}
```

- Go to /packages/core and run `npmn dev`

---------

Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: Otavio Moreira Meirelles <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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