Skip to content

x-pack/filebeat/input/entityanalytics/provider/okta: don't collect defers in a loop - #54923

Open
efd6 wants to merge 2 commits into
elastic:mainfrom
efd6:okta_deferred_in_loop
Open

efd6 wants to merge 2 commits into
elastic:mainfrom
efd6:okta_deferred_in_loop

Conversation

@efd6

@efd6 efd6 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Proposed commit message

x-pack/filebeat/input/entityanalytics/provider/okta: don't collect defers in a loop

The loop deferred response body closure resulting in connections being
retained until the loop terminated. Put the body collection in a closure
to allow the body to be closed after each iteration.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 self-assigned this Nov 24, 2026
@efd6 efd6 added Filebeat Filebeat bugfix Team:Security-Service Integrations Security Service Integrations Team backport-9.5 Automated backport to the 9.5 branch backport-9.6 Automated backport to the 9.6 branch labels Nov 24, 2026
@botelastic botelastic Bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@efd6

efd6 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

/test

…fers in a loop

The loop deferred response body closure resulting in connections being
retained until the loop terminated. Put the body collection in a closure
to allow the body to be closed after each iteration.
@efd6
efd6 force-pushed the okta_deferred_in_loop branch from 2db7d13 to 502f3dc Compare November 25, 2026 01:19
@efd6
efd6 marked this pull request as ready for review November 26, 2026 00:35
@efd6
efd6 requested a review from a team as a code owner November 26, 2026 00:35
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@mergify

mergify Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions


return nil
}()
if resp.StatusCode == http.StatusTooManyRequests {

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.

cli.Do returns a nil resp on a transport error, and the closure returns that error, but resp.StatusCode is read here before err is checked, so a network failure now panics instead of returning the error. Checking err first fixes it, and also stops a lim.Update error from being dropped when the status is 429:

if err != nil {
	return nil, nil, err
}
if resp.StatusCode == http.StatusTooManyRequests {
	log.Warnw("received 429 Too Many Requests")
	retryCount++
	continue
}

This branch has not been deployed

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

Labels

backport-9.5 Automated backport to the 9.5 branch backport-9.6 Automated backport to the 9.6 branch bugfix Filebeat Filebeat Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants