Skip to content

Conversation

blakerouse
Copy link
Contributor

What does this PR do?

Now when a variable cannot be substituted it will return an error instead of silently removing the input. Adds new syntax for |? at the end of a variable chain to allow the previous behavior.

Why is it important?

Previously, when a variable didn't exist, the entire input would be silently removed without any error or log message. This change fixes that behavior by throwing an error when a variable cannot be substituted in an input.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • 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
  • [ ] I have added an integration test or an E2E test (covered by unit tests)

Disruptive User Impact

This will require users to update the policy or configuration if they want the previous behavior.

How to test this PR locally

  1. Add a missing variable into your policy and configuration and then run the Elastic Agent. You will see the following error:
{"log.level":"error","@timestamp":"2025-10-16T10:14:27.653-0400","log.origin":{"function":"github.com/elastic/elastic-agent/internal/pkg/agent/application/coordinator.(*Coordinator).runLoopIteration","file.name":"coordinator/coordinator.go","file.line":1526},"message":"applying new policy: generating component model: rendering inputs failed: no matching vars: ${env.MISSING_VAR}","log":{"source":"elastic-agent"},"ecs.version":"1.6.0"}
  1. Add the |? at the end and run it again, see that no error is logged and that the input is missing.

Related issues

@blakerouse blakerouse self-assigned this Oct 16, 2025
@blakerouse blakerouse requested a review from a team as a code owner October 16, 2025 14:15
@blakerouse blakerouse added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-skip labels Oct 16, 2025
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@blakerouse
Copy link
Contributor Author

This has an issue with kubernetes and hints. I am going to have to look into that more and see if this approach will even work with that, might not be possible.

@blakerouse blakerouse marked this pull request as draft October 16, 2025 19:26
@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 17, 2025

💔 Build Failed

Failed CI Steps

History

cc @blakerouse

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

Labels

backport-skip Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inputs with incomplete variable substitutions will be silently ignored

2 participants