Skip to content

Fix region loss in gateway billing usage - #2594

Merged
erichare merged 3 commits into
mainfrom
fix/gateway-billing-region
Sep 28, 2026
Merged

erichare merged 3 commits into
mainfrom
fix/gateway-billing-region

Conversation

@erichare

@erichare erichare commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

Gateway embedding and reranking responses rebuild the tenant from its ID alone, causing billing events to contain UNKNOWN_REGION and fail downstream region resolution. Preserve the original request tenant when converting gateway usage, and reject responses whose tenant ID does not match the request. No gateway protocol changes are required.

A mismatched gateway tenant ID deliberately fails the command with UNEXPECTED_SERVER_ERROR to guard against a response being attributed to the wrong tenant. Both IDs are logged only on the server; the client-facing error remains generic. Case-only differences are accepted, including Cassandra's SINGLE-TENANT / single-tenant round trip.

Both gateway client regression tests reproduced UNKNOWN_REGION before the fix. Afterward, all 99 focused gateway, billing, and tenant tests passed:

./mvnw -B -ntp test -Dtest=EmbeddingGatewayClientTest,RerankingGatewayClientTest,ModelUsageTest,DefaultBillingTest,TenantTests,SubdomainTenantResolverTests -DskipITs

Which issue(s) this PR fixes:

None linked.

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 54.58% 🍏
Files changed 100% 🍏

File Coverage
RerankingEGWClient.java 81.42% 🍏
ModelUsage.java 59.76% 🍏
EmbeddingGatewayClient.java 58.33% 🍏
ProviderBase.java 54.2% 🍏

@erichare
erichare marked this pull request as ready for review September 28, 2026 17:09
@erichare
erichare requested a review from a team as a code owner September 28, 2026 17:09
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 72.03%
This PR 72.01%
Delta 🔴 -0.02%
⚠️ Coverage decreased

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 72.01% -0.03% 🍏
Files changed 11.43% ❌

File Coverage
ProviderBase.java 48.68% -0.96% ❌
ModelUsage.java 43.06% -4.94% ❌
RerankingEGWClient.java 0% -1.64% ❌
EmbeddingGatewayClient.java 0% -0.96% ❌

@github-actions

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 73.27%
This PR 73.26%
Delta 🔴 -0.01%
⚠️ Coverage decreased

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 73.26% -0.03% 🍏
Files changed 11.43% ❌

File Coverage
ProviderBase.java 48.68% -0.96% ❌
ModelUsage.java 43.06% -4.94% ❌
RerankingEGWClient.java 0% -1.64% ❌
EmbeddingGatewayClient.java 0% -0.96% ❌

@Hazel-Datastax Hazel-Datastax 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.

lgtm

@erichare
erichare merged commit 94d73b3 into main Sep 28, 2026
3 checks passed
@erichare
erichare deleted the fix/gateway-billing-region branch September 28, 2026 19:37
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