fix(datadog): billable-summary 400 (month must be YYYY-MM) + pagination SIGSEGV - #86
Open
scottt732 wants to merge 2 commits into
Open
fix(datadog): billable-summary 400 (month must be YYYY-MM) + pagination SIGSEGV#86scottt732 wants to merge 2 commits into
scottt732 wants to merge 2 commits into
Conversation
… API requires
The Datadog API now rejects /api/v1/usage/billable-summary requests whose
month query parameter is a full RFC3339 timestamp, which is what the
generated datadog-api-client-go emits for time.Time parameters (current
client master included):
400 Bad Request: month must be in the format YYYY-MM
Since GetDDUnitPrices has no fallback, this made every GetCustomCosts
window fail, rendering the plugin unable to retrieve any costs.
Add a small http.RoundTripper that rewrites the month parameter to
YYYY-MM in transit, scoped to the billable-summary path. Doing it at the
transport layer keeps the fix independent of the client library version
and is a no-op if the client ever starts emitting YYYY-MM itself.
Fixes opencost#85
…SEGV) Install the MonthParamRoundTripper on the Datadog API client so the billable-summary month parameter reaches the API as YYYY-MM (opencost#85). Also guard the pagination NextRecordId deref: NullableString.IsSet() returns true when the API sends an explicit JSON null at the end of pagination, but Get() then returns nil, so the existing check crashed with SIGSEGV once pricing succeeded. Same fix as the now-stale opencost#70. With both changes the plugin retrieves real costs end-to-end again (verified against a live us5 Datadog org). Fixes opencost#68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR change?
GET /api/v1/usage/billable-summarycall, which the Datadog API now rejects with400 Bad Request: month must be in the format YYYY-MMbecause the generated datadog-api-client-go serializes themonthparameter as a full RFC3339 timestamp (current client master does too, so a dependency bump cannot fix this). A smallhttp.RoundTripperrewrites the parameter toYYYY-MMin transit, scoped to the billable-summary path — version-proof against the client library, and a no-op if the client ever emitsYYYY-MMitself.NextRecordIddereference ingetDDCostsForWindow:NullableString.IsSet()returns true for an explicit JSONnullat end of pagination whileGet()returns nil, so once pricing succeeds the plugin crashes with SIGSEGV. Same fix as the now-stale fix(datadog): add nil check for NextRecordId in pagination logic (#68) #70.Does this PR relate to any other PRs?
How will this PR impact users?
Does this PR address any GitHub or Zendesk issues?
How was this PR tested?
YYYY-MM, other endpoints untouched).curl— RFC3339 month rejected,YYYY-MMaccepted with the same credentials.main.go:237once pricing succeeds.go build ./...,go vet ./...,go test ./datadogplugin/...all clean.Does this PR require changes to documentation?