Skip to content

fix(datadog): add nil check for NextRecordId in pagination logic (#68)#70

Open
1PoPTRoN wants to merge 1 commit intoopencost:mainfrom
1PoPTRoN:fix/issue-68
Open

fix(datadog): add nil check for NextRecordId in pagination logic (#68)#70
1PoPTRoN wants to merge 1 commit intoopencost:mainfrom
1PoPTRoN:fix/issue-68

Conversation

@1PoPTRoN
Copy link

What does this PR change?

  • Adds a safe nil check when retrieving NextRecordId from the Datadog API response in the hourly cost retrieval logic.
  • Prevents a SIGSEGV (segmentation violation) that occurred when the Datadog API returned a "set" optional value for the pagination token that contained a nil pointer.

Does this PR relate to any other PRs?

  • N/A

How will this PR impact users?

  • Improves the stability and reliability of the Datadog plugin. Users with large Datadog datasets requiring pagination will no longer experience random crashes during cost ingestion.

Does this PR address any GitHub or Zendesk issues?

How was this PR tested?

  • Unit Tests: Ran go test ./... in the pkg/plugins/datadog directory. All existing tests passed successfully.
  • Build Verification: Successfully compiled the Datadog plugin for multiple platforms (linux/arm64, linux/amd64, darwin/arm64, darwin/amd64) using the project's tools/build-plugins script.
  • Logical Validation: Verified that the fix correctly implements the safety pattern required by the Datadog Go SDK's Nullable types.

Does this PR require changes to documentation?

  • No.

Copilot AI review requested due to automatic review settings February 16, 2026 20:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Datadog plugin’s hourly cost pagination loop by preventing a nil-pointer dereference when the Datadog SDK marks NextRecordId as “set” but the underlying pointer returned by .Get() is nil (issue #68).

Changes:

  • Add a defensive nil check around resp.Meta.Pagination.NextRecordId.Get() before dereferencing.
  • Ensure pagination terminates safely by falling back to an empty nextPageId when the token is missing or nil.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ost#68)

Signed-off-by: 1PoPTRoN <vrxn.arp1traj@gmail.com>
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.

[BUG] Datadog plugin crashes with SIGSEGV in getDDCostsForWindow - nil pointer dereference

1 participant