Skip to content

fix(gcp/cloudstorage): apply the currency unification to the Cloud Storage extractor - #424

Draft
IAmJSD wants to merge 1 commit into
LeanerCloud:mainfrom
IAmJSD:fix/issue-243
Draft

IAmJSD wants to merge 1 commit into
LeanerCloud:mainfrom
IAmJSD:fix/issue-243

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Oct 15, 2026

Copy link
Copy Markdown

Root cause

extractStoragePricingFromSKUs (providers/gcp/services/cloudstorage/client.go) seeded currency = "USD" and then overwrote it with the currency of whichever priced SKU came last. A catalog result with mixed currencies, or SKUs with no currency code, therefore reported a currency that did not match the prices it summed. This is the Cloud Storage slice of #102 that #239 left out because #205 (now merged) touched the same file.

Fix

Mirrors #239 exactly for Cloud Storage: the USD seed is removed and each priced SKU's currency is folded in with billingcurrency.Unify(currency, curr, sku.SkuId), returning its error. A missing or conflicting currency now fails pricing instead of mislabelling it. No hardcoded "USD" remains in client.go.

The regression test providers/gcp/services/cloudstorage/pricing_currency_test.go uses the same table as cloudsql/pricing_currency_test.go and goes through getStoragePricing with a mocked billing service: consistent EUR, consistent USD, mixed USD/EUR, and a missing commitment or on-demand currency.

Closes #243

Verification

All of this ran locally on macOS against mocked Cloud Billing Catalog responses. No real GCP APIs were called.

Fail before the fix (test added, client.go unchanged):

cd providers/gcp && AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null go test ./services/cloudstorage/ -run TestGetStoragePricing_Currency
--- FAIL: TestGetStoragePricing_Currency/on-demand_and_commitment_currencies_differ  (An error is expected but got nil.)
--- FAIL: TestGetStoragePricing_Currency/commitment_currency_missing
--- FAIL: TestGetStoragePricing_Currency/on-demand_currency_missing
FAIL

Pass after the fix:

cd providers/gcp
go build ./...                       # ok
go vet ./...                         # ok
go test -race -short ./...           # all packages ok, including services/cloudstorage
golangci-lint run --timeout=5m       # v2.10.1: 0 issues

AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null was set because of an invalid default AWS profile on the author's machine. It has no effect on this GCP-only change.

Gap: this was not checked against a live Cloud Billing Catalog response in a non-USD billing account.

Out of scope: #412 added CommitmentCurrency for Cloud SQL, Memorystore and Compute Engine. Cloud Storage does not produce recommendations (GetRecommendations is not supported), so that part was not applied here.

Labels

The author lacks label permissions. Could a maintainer please mirror the issue's triage labels onto this PR: priority/p2, severity/medium, urgency/this-sprint, impact/few, effort/xs, type/bug, triaged.

🤖 Generated with Claude Code

…of seeding USD

Cloud Storage pricing seeded currency to USD and let each later priced SKU
overwrite it, so a catalog result with mixed or missing currencies reported
a currency that did not match the prices it summed. The currency now comes
from the priced SKUs via billingcurrency.Unify, as Cloud SQL and Memorystore
do since LeanerCloud#239, and a missing or conflicting one is an error.

Closes LeanerCloud#243

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member

Independent review verdict: CLEAN at 38a6affd8194e0df6fadc81f3f3948d0bc75d601 (merge driver; reviewer did not write the code; base main 740dfbd72456)

  • Compared side by side with cloudsql: cloudstorage/client.go:283-312 vs cloudsql/client.go:430-443. The order matches: skip zero price, billingcurrency.Unify, return on error, skumatch.Slot. The USD seed is gone. Unpriced or unmatched SKUs never reach Unify.
  • Callers: getStoragePricing (client.go:244) propagates the error. GetOfferingDetails (client.go:176) wraps it.
  • Mutation probes, both killed: (1) swallowing the Unify error made TestGetStoragePricing_Currency fail; (2) re-seeding "USD" made the EUR and missing-commitment cases fail.
  • Local verification on macOS (fixture/mock evidence, mocked Cloud Billing Catalog, no live GCP call): cd providers/gcp && go test -race -short ./... passes, and go vet ./... passes.
  • Non-blocking: a SKU that matches class and region but neither slot still has its currency unified when its price is nonzero. cloudsql does the same.

Remaining merge gates: CI has not run (the fork workflows are awaiting maintainer approval). The PR is a draft. Labels still need mirroring from #243. CR has not reviewed this head because the PR is a draft.

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

Labels

effort/xs Trivial / one-liner impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gcp/cloudstorage): apply the currency unification to the Cloud Storage extractor

2 participants