Skip to content

fix: default empty Provider to tencentcloud in ExpectedCurrencyFor - #8

Merged
susunola merged 1 commit into
susunola:mainfrom
cowboysbff:fix/empty-provider-currency-fallback
Aug 3, 2026
Merged

susunola merged 1 commit into
susunola:mainfrom
cowboysbff:fix/empty-provider-currency-fallback

Conversation

@cowboysbff

Copy link
Copy Markdown
Contributor

Problem

Tencent Cloud mappers do not set the Provider field on PriceRequest (predating multi-cloud support). When ExpectedCurrencyFor("") is called, the empty string doesn't match case "tencentcloud" in the switch statement, so it falls through to the default "CNY" — even when --site intl is specified.

This causes CBS, CLB, CynosDB, CVM, DCDB, EIP, MariaDB, and VPN Gateway to incorrectly report CNY instead of USD on the international site.

Root Cause

// main.go line 648
parseReq.ExpectedCurrency = engine.ExpectedCurrencyFor(req.Provider)
// req.Provider is "" for all Tencent mappers

ExpectedCurrencyFor(""):

  • """ != "tencentcloud" → falls through → returns "CNY"

Fix

Treat empty provider as "tencentcloud" at the top of ExpectedCurrencyFor, consistent with the existing provider() method convention that already treats empty as tencentcloud.

Before / After

Product Before After
CBS, CLB, CynosDB, CVM, DCDB, EIP, MariaDB, VPN CNY ❌ USD ✅
MySQL, PostgreSQL, Redis USD ✅ (unaffected, they read Currency from API response) USD ✅

All tests pass (go test ./...).

Tencent Cloud mappers do not set the Provider field on PriceRequest
(predating multi-cloud support). ExpectedCurrencyFor("") fell through
to the default "CNY" even when --site intl was specified, causing CBS,
CLB, CynosDB, CVM, DCDB, EIP, MariaDB and VPN to report CNY instead
of USD on international site.

Fix: treat empty provider as "tencentcloud", consistent with the
existing provider() method convention.
@susunola
susunola merged commit e94f32b into susunola:main Aug 3, 2026
2 checks passed
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