Skip to content

Bug: processor condition doesn't allow dict access to .Metadata #2258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rauanmayemir opened this issue Apr 21, 2025 · 1 comment
Closed
Labels
bug Something isn't working triage Needs to be triaged

Comments

@rauanmayemir
Copy link

Bug description

Processor crashes with:

failed to build source processor tasks: invalid condition: template: :1: bad character U+005B '['" stack=[{"file":"github.com/conduitio/[email protected]/pkg/provisioning/service.go","func":"github.com/conduitio/conduit/pkg/provisioning.(*Service).Init","line":132},{"file":"github.com/conduitio/[email protected]/pkg/provisioning/service.go","func":"github.com/conduitio/conduit/pkg/provisioning.(*Service).provisionPipeline","line":260},{"file":"github.com/conduitio/[email protected]/pkg/lifecycle-poc/service.go","func":"github.com/conduitio/conduit/pkg/lifecycle-poc.(*Service).Start","line":159},{"file":"github.com/conduitio/[email protected]/pkg/lifecycle-poc/service.go","func":"github.com/conduitio/conduit/pkg/lifecycle-poc.(*Service).buildRunnablePipeline","line":301},{"file":"github.com/conduitio/[email protected]/pkg/lifecycle-poc/service.go","func":"github.com/conduitio/conduit/pkg/lifecycle-poc.(*Service).buildSourceTasks","line":411},{"file":"github.com/conduitio/[email protected]/pkg/processor/service.go","func":"github.com/conduitio/conduit/pkg/processor.(*Service).MakeRunnableProcessor","line":105}]

Steps to reproduce

Have a processor with a condition like this:

- id: route_default
  plugin: 'filter'
  condition: '{{ ne .Metadata["outbox.route"] "default" }}'

Version

v0.13.4

@rauanmayemir rauanmayemir added bug Something isn't working triage Needs to be triaged labels Apr 21, 2025
@lovromazgon
Copy link
Member

That's because the condition is a pure Go template and doesn't accept the map syntax. You have to use the index function to access the field:

{{ ne (index .Metadata "outbox.route") "default" }}

Runnable example: https://go.dev/play/p/XXAeCG6wTET

The confusing part might be that Conduit accepts the syntax you wrote above when referencing record fields. That only applies to certain configuration options in processors, mostly ones called field that configure the processor to work on a specific field (for instance field in avro.decode). This syntax should not be confused with Go templates, even if they look similar.

@github-project-automation github-project-automation bot moved this from Triage to Done in Conduit Main Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Needs to be triaged
Projects
Status: Done
Development

No branches or pull requests

2 participants