Skip to content

[Otel] Beatsauthextension: respect continue_on_error in Validate - #53811

Merged
belimawr merged 8 commits into
mainfrom
fix-beats-auth-continue-on-error
Oct 19, 2026
Merged

belimawr merged 8 commits into
mainfrom
fix-beats-auth-continue-on-error

Conversation

@belimawr

@belimawr belimawr commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Proposed commit message

I continue_on_error: true the first error (config validation or http client instantiation) is logged at warn level, reported as permanent error and returned in any use of the created roundtripper.

Assisted-by: gpt-5.6-terra-high

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

Unit tests

go test -count=1 ./x-pack/otel/extension/beatsauthextension

Manual test

1. Build the Beats OTel Collector

cd x-pack/otel
mage buildOtelDistro

2. Create a log file

printf 'beatsauth continue_on_error test\n' > /tmp/beatsauth-input.log

3. Write the Collector configuration

/tmp/beatsauth-continue-on-error.yaml

extensions:
  beatsauth:
    continue_on_error: true
    endpoints:
      - tcp://es.example:9200

receivers:
  filelog:
    include: [/tmp/beatsauth-input.log]
    start_at: beginning

exporters:
  elasticsearch:
    auth:
      authenticator: beatsauth
    endpoints:
      - http://127.0.0.1:9200

service:
  extensions: [beatsauth]
  pipelines:
    logs:
      receivers: [filelog]
      exporters: [elasticsearch]
  telemetry:
    logs:
      level: info
    metrics:
      level: none

4. Start the Collector

cd distributions/beats-otel-collector/_build/
./beats-otel-collector --config /tmp/beatsauth-continue-on-error.yaml

Expected: the Collector starts despite tcp://es.example:9200 being invalid and remains running. Startup logs exactly one warning containing invalid endpoint: URL scheme must be http or https; the filelog record triggers an Elasticsearch exporter failure with the same error.

Related issues

## Use cases
## Screenshots
## Logs

@belimawr belimawr self-assigned this Oct 15, 2026
@belimawr belimawr added backport-skip Skip notification from the automated backport with mergify Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team skip-changelog labels Oct 15, 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 Oct 15, 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.

Copilot AI 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.

🟢 Approval recommended

The focused fix reuses the existing startup fallback and includes regression coverage for both settings, with no unresolved findings.

0 open findings

What changed in this PR

Fixes #53800 by allowing beatsauth transport configuration errors to reach the existing startup fallback when continue_on_error is enabled.

Changes:

  • Defers configuration errors to startup when enabled, preserving default validation behavior otherwise.
  • Adds regression tests for invalid TLS certificates with both settings.
File Description
x-pack/​otel/​extension/​beatsauthextension/​config.go Honors ContinueOnError during configuration validation.
x-pack/​otel/​extension/​beatsauthextension/​authenticator_test.go Tests TLS validation with and without error continuation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@belimawr
belimawr marked this pull request as ready for review October 15, 2026 18:53
@belimawr
belimawr requested a review from a team as a code owner October 15, 2026 18:53
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@belimawr belimawr changed the title Respect continue_on_error in Validate [Otel] Beatsauthextension: respect continue_on_error in Validate Oct 15, 2026
@belimawr
belimawr requested a review from khushijain21 October 16, 2026 17:09
@belimawr
belimawr enabled auto-merge (squash) October 16, 2026 17:11
Assisted-by: gpt-5.6-terra-high

Copilot AI 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.

🟢 Approval recommended

Static review identified no blocking issues in the focused fix and regression coverage; tests were not executed.

0 open findings

🧠 Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

golangci-lint failed in all matrix jobs (macos, ubuntu, windows) on the same bodyclose issue in x-pack/otel/extension/beatsauthextension/authenticator_test.go at line 388. Update the test helper to close resp.Body in a linter-recognized pattern (e.g., immediate defer resp.Body.Close() after the Get succeeds).

Remediation

  • In x-pack/otel/extension/beatsauthextension/authenticator_test.go (doGET helper, around client.Get(url)), replace the current explicit close style with:
    • resp, err := client.Get(url)
    • require.NoError(t, err)
    • defer func() { require.NoError(t, resp.Body.Close()) }()
  • Re-run the same lint target used by CI (or at least golangci-lint for this package) to confirm bodyclose no longer reports.
Investigation details

Root Cause

The golangci-lint bodyclose check reports an unclosed response body in the test helper path at authenticator_test.go:388:43. The workflow fails because this lint finding is treated as an error.

Evidence

  • Workflow: https://github.com/elastic/beats/actions/runs/38956860431
  • Job/step: lint (ubuntu-latest) → golangci-lint (same failure also in lint (macos-latest) and lint (windows-latest))
  • Key log excerpt:
    • ##[error]x-pack/otel/extension/beatsauthextension/authenticator_test.go:388:43: response body must be closed (bodyclose)
    • ##[error]issues found

Validation

  • Local tests/commands: not run in this workflow investigation environment (read-only diagnostic run).

Follow-up

  • If this is intended to stay as a direct close instead of defer, use whichever close pattern your lint config reliably recognizes; the current pattern is not accepted by bodyclose in CI.

What is this? | From workflow: PR Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@belimawr
belimawr requested a review from cmacknz October 16, 2026 19:58

@andrzej-stencel andrzej-stencel 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.

I agree with the above Craig's comment. We should not need the validateErr field on the config. Instead, return nil from Validate straight away if continue_on_error is true and validate separately in Start.

@andrzej-stencel

Copy link
Copy Markdown
Contributor

I've disabled automerge until the comments are resolved.

@cmacknz cmacknz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this now defers when the error is reported allowing the collector to start as we want.

@mergify

mergify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@belimawr

Copy link
Copy Markdown
Member Author

@mergify backport 9.6

@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

backport 9.6

✅ Backports have been created

Details
  • Backport to branch 9.6 completed

No pull request needed: No commits between 9.6 and mergify/bp/9.6/pr-53811

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

Labels

backport-9.6 Automated backport to the 9.6 branch skip-changelog Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Otel] beatsauth: continue_on_error does not cover configuration validation errors

5 participants