Skip to content

copy-input-headers property not working for function configuration #1273

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

Open
allanewrynn opened this issue Apr 23, 2025 · 0 comments
Open

Comments

@allanewrynn
Copy link

Describe the bug

spring-cloud-function-context 4.2.2
spring-boot 3.4.4
spring-boot-starter-amqp 3.4.4

I have a Function bean:

 @Bean
 public Function<Message<?>, Object> transform() {
     return message -> {
         return transformerService.transform(message);
     };
 }

which accepts a Message<?> and returns an Object. I want to propagate the headers from the input message to the output.

This documentation input_header_propagation tells me that I can set a property
spring.cloud.function.configuration.transform.copy-input-headers=true
and the input headers will be propagated to the output.

Unfortunately this does not work.

The only way I can get it to work is by manually copying the headers and return a Message<?> instead of an Object.

I stepped through the debugger of SimpleFunctionRegistry.java and what I saw:

  1. it sets propagateInputHeaders to the value of copyInputHeaders - so true in my case
  2. propagateInputHeaders is only used here
      private boolean isExtractPayload(Message<?> message, Type type) {
	  if (this.propagateInputHeaders || this.isRoutingFunction() || FunctionTypeUtils.isMessage(type)) {
		return false;
          }
         .... 
         ....
         // rest of code
  1. That's it, that's all propagateInputHeaders does and it's not used anywhere else nor is copyInputHeaders used anywhere else.

It would be great if the property worked so that a manual copy in the code isn't necessary and it would allow a Function to return an Object rather than forced to return a Message<?>.

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

No branches or pull requests

1 participant