Skip to content

Conversation

@Phantal
Copy link

@Phantal Phantal commented Jan 31, 2026

Summary

Enable template support in rpk connect test by explicitly passing the environment to the manager.

Problem

Templates loaded via the -t flag were not recognized during test execution (see benthos issue 287):

rpk connect test -t template.yaml test.yaml
# Error: processor type 'my_template' was not recognised

rpk connect run -t template.yaml config.yaml
# Works correctly ✓

Root Cause

RPK creates a cloned environment at startup via service.NewEnvironment(). When templates are registered, they're added to this cloned environment, not bundle.GlobalEnvironment. The test command's manager was created without explicitly passing the environment, causing it to default to bundle.GlobalEnvironment (which doesn't have templates).

Execution flow:

  1. RPK clones environment → schema.Environment() (has built-in processors)
  2. Templates register → schema.Environment() (now has templates too)
  3. ProcessorsProvider receives → schema.Environment() (parsing works ✓)
  4. Manager created with default → bundle.GlobalEnvironment (no templates ✗)

Solution

Pass the environment explicitly when creating the manager, matching the pattern used by the run command (internal/cli/common/manager.go:107).

Files changed:

  • internal/cli/test/processors_provider.go - Add manager.OptSetEnvironment(p.env)
  • internal/cli/test/processors_provider_test.go - Add integration test

Testing

  • ✅ All existing tests pass
  • ✅ New integration test verifies templates work with cloned environments
  • ✅ Manual test: benthos test -t template.yaml test.yaml succeeds

Notes

  • This issue only affects RPK (which uses cloned environments)
  • Standalone Benthos is unaffected (uses bundle.GlobalEnvironment directly)
  • The fix is minimal and follows established patterns

@CLAassistant
Copy link

CLAassistant commented Jan 31, 2026

CLA assistant check
All committers have signed the CLA.

Templates loaded via the -t flag were not available during test execution
because the manager defaulted to bundle.GlobalEnvironment instead of using
the environment where templates were registered.
This fix explicitly passes the environment to the manager, matching the
pattern used by the run command (internal/cli/common/manager.go:107).
The issue only affects RPK, which uses a cloned environment rather than
bundle.GlobalEnvironment directly. Standalone Benthos is unaffected.
Changes:
- Add manager.OptSetEnvironment(p.env) in processors_provider.go
- Add integration test verifying templates work with ProcessorsProvider
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.

2 participants