Skip to content

outputs: remove redundant beatPaths parameter from Factory#49839

Open
orestisfl wants to merge 2 commits intoelastic:mainfrom
orestisfl:outputs-use-info-paths
Open

outputs: remove redundant beatPaths parameter from Factory#49839
orestisfl wants to merge 2 commits intoelastic:mainfrom
orestisfl:outputs-use-info-paths

Conversation

@orestisfl
Copy link
Copy Markdown
Contributor

@orestisfl orestisfl commented Apr 1, 2026

Proposed commit message

outputs: remove beatPaths parameter from Factory type

The output Factory function type and Load helper both accepted a
*paths.Path that duplicated what beat.Info already carries. Drop the
parameter from the public interface and have each output
implementation read paths from beat.Paths when calling Success or
SuccessNet.

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.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None. Internal API change only.

How to test this PR locally

Related issues

@orestisfl orestisfl added refactoring Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-active-all Automated backport with mergify to all the active branches skip-changelog labels Apr 1, 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 Apr 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@orestisfl orestisfl linked an issue Apr 1, 2026 that may be closed by this pull request
@github-actions

This comment has been minimized.

@orestisfl orestisfl force-pushed the outputs-use-info-paths branch 2 times, most recently from 16c045b to 0f9b932 Compare April 1, 2026 14:30
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 7, 2026

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b outputs-use-info-paths upstream/outputs-use-info-paths
git merge upstream/main
git push upstream outputs-use-info-paths

Now that Paths lives in beat.Info, output factories can access
paths via the Info parameter. The separate paths argument is
no longer needed in the Factory type or Load function.
@orestisfl orestisfl force-pushed the outputs-use-info-paths branch from 0f9b932 to 5adeee3 Compare April 17, 2026 10:30
@orestisfl orestisfl marked this pull request as ready for review April 17, 2026 10:36
@orestisfl orestisfl requested a review from a team as a code owner April 17, 2026 10:36
@orestisfl orestisfl requested review from faec and mauri870 April 17, 2026 10:36
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

📝 Walkthrough

Walkthrough

This change removes the explicit beatPaths *paths.Path parameter from output factory functions across the libbeat codebase. The Factory type and Load function signatures in libbeat/outputs/output_reg.go are updated to eliminate this parameter. Output makers (makeConsole, makeES, makeKafka, etc.) are modified to source path information from beat.Info.Paths instead of receiving it as a separate argument. Corresponding call sites and tests are updated to reflect the reduced parameter set.

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
libbeat/publisher/pipeline/stress/run.go (1)

70-93: ⚠️ Potential issue | 🟠 Major

RunTests does not propagate constructed paths to output factories.

The function creates beatPaths (lines 70–75) and assigns it to pipelineSettings.Paths, but output factories receive info with its original Paths field unset. Multiple outputs (elasticsearch, logstash, kafka, redis, fileout, console, discard) explicitly use beat.Paths, so this leaves them without proper path configuration.

Add info.Paths = beatPaths after the local paths initialization to ensure outputs receive the intended configuration.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libbeat/publisher/pipeline/stress/run.go` around lines 70 - 93, The
constructed local beatPaths are assigned to pipelineSettings.Paths but not
injected into the Beat info passed to output factories; update the RunTests
function to set info.Paths = beatPaths immediately after creating beatPaths
(after beatPaths.Home/Config/Data/Logs are set) so that outputs loaded by
outputs.Load (inside the anonymous factory passed to pipeline.LoadWithSettings)
receive the proper Paths configuration; keep the existing pipelineSettings
assignment to Paths as well.
x-pack/dockerlogbeat/pipelinemanager/libbeattools.go (1)

68-75: ⚠️ Potential issue | 🔴 Critical

info.Paths is not populated before outputs.Load, so path-aware outputs can fail

Line 87 now relies on beat.Info.Paths, but this file never assigns beatPaths into info.Paths. That can break outputs that resolve files/certs/templates via beat paths.

Suggested fix
@@
 	info, err := getBeatInfo(logOptsConfig, hostname, log)
 	if err != nil {
 		return nil, err
 	}
 
+	beatPaths := paths.New()
+	info.Paths = beatPaths
+
 	processing, err := processing.MakeDefaultBeatSupport(true)(info, log, cfg)
 	if err != nil {
 		return nil, fmt.Errorf("error in MakeDefaultSupport: %w", err)
 	}
@@
-	beatPaths := paths.New()
-
 	settings := pipeline.Settings{
 		WaitClose:     time.Second * 10,
 		WaitCloseMode: pipeline.WaitOnPipelineClose,
 		Processors:    processing,
 		Paths:         beatPaths,
 	}

Also applies to: 87-88

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@x-pack/dockerlogbeat/pipelinemanager/libbeattools.go` around lines 68 - 75,
The code constructs beatPaths and passes it into pipeline.Settings but does not
assign those paths to beat.Info.Paths before calling outputs.Load, causing
path-aware outputs to fail; fix by setting info.Paths = beatPaths (or otherwise
populating the beat.Info object used by outputs.Load) prior to calling
outputs.Load so outputs can resolve files/certs/templates correctly — update the
code around where beatPaths is created and before outputs.Load is invoked
(referencing beatPaths, pipeline.Settings, outputs.Load, and beat.Info.Paths).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@libbeat/publisher/pipeline/stress/run.go`:
- Around line 70-93: The constructed local beatPaths are assigned to
pipelineSettings.Paths but not injected into the Beat info passed to output
factories; update the RunTests function to set info.Paths = beatPaths
immediately after creating beatPaths (after beatPaths.Home/Config/Data/Logs are
set) so that outputs loaded by outputs.Load (inside the anonymous factory passed
to pipeline.LoadWithSettings) receive the proper Paths configuration; keep the
existing pipelineSettings assignment to Paths as well.

In `@x-pack/dockerlogbeat/pipelinemanager/libbeattools.go`:
- Around line 68-75: The code constructs beatPaths and passes it into
pipeline.Settings but does not assign those paths to beat.Info.Paths before
calling outputs.Load, causing path-aware outputs to fail; fix by setting
info.Paths = beatPaths (or otherwise populating the beat.Info object used by
outputs.Load) prior to calling outputs.Load so outputs can resolve
files/certs/templates correctly — update the code around where beatPaths is
created and before outputs.Load is invoked (referencing beatPaths,
pipeline.Settings, outputs.Load, and beat.Info.Paths).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 47d8be26-9287-42c8-8328-8f2eb79b1618

📥 Commits

Reviewing files that changed from the base of the PR and between 184a91b and 5adeee3.

📒 Files selected for processing (20)
  • libbeat/cmd/instance/beat.go
  • libbeat/cmd/test/output.go
  • libbeat/outputs/console/console.go
  • libbeat/outputs/discard/discard.go
  • libbeat/outputs/elasticsearch/client_integration_test.go
  • libbeat/outputs/elasticsearch/elasticsearch.go
  • libbeat/outputs/fileout/file.go
  • libbeat/outputs/kafka/client_test.go
  • libbeat/outputs/kafka/kafka.go
  • libbeat/outputs/kafka/kafka_integration_test.go
  • libbeat/outputs/logstash/logstash.go
  • libbeat/outputs/logstash/logstash_integration_test.go
  • libbeat/outputs/logstash/logstash_test.go
  • libbeat/outputs/output_reg.go
  • libbeat/outputs/redis/redis.go
  • libbeat/outputs/redis/redis_integration_test.go
  • libbeat/outputs/redis/redis_test.go
  • libbeat/publisher/pipeline/stress/out.go
  • libbeat/publisher/pipeline/stress/run.go
  • x-pack/dockerlogbeat/pipelinemanager/libbeattools.go

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

TL;DR

make -C libbeat check update fails in go vet due to a makeConsole signature mismatch in console output tests: the tests pass 5 args, but the function on this PR branch expects 4.

Remediation

  • Update both test call sites in libbeat/outputs/console/console_test.go (:160 and :203) to match the current makeConsole signature (remove the trailing nil if the function now has 4 parameters).
  • Re-run make -C libbeat check (or cd libbeat && go vet ./...) to confirm the mismatch is resolved.
Investigation details

Root Cause

The failing step is a compile-time/vet error in libbeat/outputs/console/console_test.go. The test calls:

  • makeConsole(nil, beat.Info{Beat: "test", Logger: logger}, outputs.NewNilObserver(), cfg, nil) at libbeat/outputs/console/console_test.go:160
  • makeConsole(nil, beat.Info{Beat: "test", Logger: logger}, outputs.NewNilObserver(), cfg, nil) at libbeat/outputs/console/console_test.go:203

Buildkite reports that makeConsole currently accepts only 4 parameters on this PR branch.

Evidence

vet: outputs/console/console_test.go:160:116: too many arguments in call to makeConsole
  have (nil, beat.Info, outputs.Observer, *config.C, nil)
  want (outputs.IndexManager, beat.Info, outputs.Observer, *config.C)
Error: failed running go vet, please fix the issues reported: running "go vet ./..." failed with exit code 1

Verification

  • Local reproduction against the exact PR commit was not run because commit 01df05a42c0cc49e7ce655b1c15c32c0e41c3e2e is not present in this checkout.
  • Root cause is directly evidenced by the Buildkite log excerpt above.

Follow-up

After fixing the two call sites, check whether any additional tests in libbeat/outputs/console still call makeConsole with the old argument list.

Note

🔒 Integrity filter blocked 2 items

The following items were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

What is this? | From workflow: PR Buildkite Detective

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

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

Labels

backport-active-all Automated backport with mergify to all the active branches refactoring 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.

[beatreceiver] move paths object into Beat.Info

2 participants