Skip to content

fix(gcp): fail on missing or mixed SKU currency instead of seeding USD - #239

Merged
cristim merged 1 commit into
mainfrom
fix/gcp-sku-currency-102
Oct 6, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/gcp-sku-currency-102

Conversation

@cristim

@cristim cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member

What

Cloud SQL (providers/gcp/services/cloudsql) and Memorystore (providers/gcp/services/memorystore) pricing no longer seed the currency to USD and overwrite it with whichever SKU came last. Each SKU that contributes a price must carry a currency code, and all contributing SKUs must agree; otherwise the lookup returns an error. A consistent non-USD currency is returned as that currency. This follows the policy of the Azure fixes (#179-#187).

A small shared helper, providers/gcp/internal/billingcurrency.Unify, holds the rule and is used by both extractors.

Why

Same defect as the Azure half of #102: a missing or conflicting currency silently produced a mislabelled on-demand/commitment pair and a savings percentage computed across denominations.

Source of truth (Cloud Billing Catalog API, google.golang.org/api v0.274.0, cloudbilling/v1/cloudbilling-gen.go)

  • Money.CurrencyCode ("three-letter ISO 4217 code") is per price: type Money at :763, field at :765.
  • Prices live in PricingInfo (:980) -> PricingExpression (:914) -> TierRate (:1231) -> UnitPrice Money.
  • The list call takes one request-level currencyCode (:3461-3463): "currency code for the pricing info in the response proto ... If not specified USD will be used." So one response is single-currency and conflicting or empty currencies among its SKUs are a data error, not a legitimate case.

Behaviour change

Callers of getSQLPricing / getRedisPricing (and so GetOfferingDetails) now get an error where they previously got a possibly wrong currency label. With no priced SKU, the extractor now returns an empty currency instead of "USD"; both callers already error on a zero on-demand price.

Scope

Refs #102, does not close it: the GCP Cloud Storage extractor (cloudstorage/client.go ~256/272) has the same shape but is also changed by open PR #205, so it is left for a follow-up. The Azure half is already on main. No request parameter was changed.

Verification

  • New table tests TestGetSQLPricing_Currency and TestGetRedisPricing_Currency (fixtures only): consistent EUR returned as EUR, consistent USD, mixed USD/EUR, missing commitment currency, missing on-demand currency.
  • On the pre-fix source the 3 mixed/missing cases fail in each package (2 consistent cases pass); after the fix all pass.
  • go vet ./... and go test ./... in providers/gcp pass; golangci-lint (repo config, run from providers/gcp) exit 0, 0 issues.
  • Not verified: no live Billing Catalog calls.

Cloud SQL and Memorystore pricing seeded currency to USD and let each later SKU overwrite it, so a SKU without a currency or with a different one produced a wrongly labelled pair. The currency now comes from the priced SKUs and a missing or conflicting one is an error. Cloud Storage has the same shape and is left to a follow-up because it overlaps #205.
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged urgency/this-quarter Within the quarter impact/few Limited audience effort/s Hours type/bug Defect labels Oct 6, 2026
@cristim

cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. Your current included review allowance is based on your included PR review attempts over the past 7 days. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 10 minutes.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 6 billable files and costs up to $1.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 10 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 57 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: b883c750-5e80-4d1d-a0ec-4588d95e48a1
📥 Commits

Reviewing files that changed from the base of the PR and between ea61b58 and a15d230.

📒 Files selected for processing (6)
  • providers/gcp/internal/billingcurrency/billingcurrency.go
  • providers/gcp/services/cloudsql/client.go
  • providers/gcp/services/cloudsql/pricing_currency_test.go
  • providers/gcp/services/memorystore/client.go
  • providers/gcp/services/memorystore/client_coverage_test.go
  • providers/gcp/services/memorystore/pricing_currency_test.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant