Skip to content
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

2.8.0 YAML config no longer working in 2.9.2 #26009

Closed
tbkahuna48 opened this issue Jun 8, 2022 · 6 comments · Fixed by #26131
Closed

2.8.0 YAML config no longer working in 2.9.2 #26009

tbkahuna48 opened this issue Jun 8, 2022 · 6 comments · Fixed by #26131
Assignees
Labels
area/config kind/bug Something isn't working
Milestone

Comments

@tbkahuna48
Copy link

tbkahuna48 commented Jun 8, 2022

The below works in 2.8.0 but not in 2.9.2.
Here are the respective configs in memory.
You will notice that. in the 2.9.2 - the map keys are messed up. It appears that the keys for the Map<String, MessageUtilConfiguration> messageUtilConfigurations() in the config file have also been used for the key for the Map<String, Map<String, MessageUtilConfiguration>> messageUtilConfigsMap();
I've highlighted the map keys which are different in the 2 versions.

correct config with 2.8.0 top map key should be "filter"

messageHandlerConfigurations	MessageUtilConfigurations249831481Impl  (id=264)	
	enableDataswapDetection	Optional<T>  (id=275)	
	messageUtilConfigsMap	HashMap<K,V>  (id=277)	
		[0]	HashMap$Node<K,V>  (id=295)	
			key	"**filter**" (id=299)	
			value	HashMap<K,V>  (id=300)	
				[0]	HashMap$Node<K,V>  (id=314)	
					key	"**default**" (id=316)	
					value	MessageUtilConfigurations$MessageUtilConfiguration-464514824Impl  (id=317)	
				[1]	HashMap$Node<K,V>  (id=315)	
		[1]	HashMap$Node<K,V>  (id=296)	
			key	"client" (id=301)	
			value	HashMap<K,V>  (id=302)	
				[0]	HashMap$Node<K,V>  (id=310)	
					key	"reaction-api" (id=312)	
					value	MessageUtilConfigurations$MessageUtilConfiguration-464514824Impl  (id=313)	
				[1]	HashMap$Node<K,V>  (id=311)	
	messageUtilConfigurations	Collections$EmptyMap<K,V>  (id=283)	
	returnDetailedError	Optional<T>  (id=285)	
requestScopedContext	RequestScopedContext_ClientProxy  (id=268)	

bad Config with 2.9.2 (no code changes) top map key seems to be the key for the contained map "default "rather than "filter"

messageHandlerConfigurations	MessageUtilConfigurations249831481Impl  (id=225)	
	enableDataswapDetection	Optional<T>  (id=250)	
	messageUtilConfigsMap	HashMap<K,V>  (id=251)	
		[0]	HashMap$Node<K,V>  (id=280)	
			key	"**default**" (id=297)	
			value	HashMap<K,V>  (id=298)	
				[0]	HashMap$Node<K,V>  (id=336)	
					key	"**default**" (id=346)	
					value	MessageUtilConfigurations$MessageUtilConfiguration-464514824Impl  (id=347)	
		[1]	HashMap$Node<K,V>  (id=281)	
			key	"reaction-api" (id=299)	
			value	HashMap<K,V>  (id=300)	
				[0]	HashMap$Node<K,V>  (id=348)	
					key	"reaction-api" (id=359)	
					value	MessageUtilConfigurations$MessageUtilConfiguration-464514824Impl  (id=360)	
		[2]	HashMap$Node<K,V>  (id=282)	
		[3]	HashMap$Node<K,V>  (id=283)	
	messageUtilConfigurations	Collections$EmptyMap<K,V>  (id=262)	
	returnDetailedError	Optional<T>  (id=264)	
requestScopedContext	RequestScopedContext_ClientProxy  (id=229)	

Config interface:

@ConfigMapping(prefix = "message-util-configurations", namingStrategy = ConfigMapping.NamingStrategy.KEBAB_CASE)
public interface MessageUtilConfigurations {

    Optional<Boolean> enableDataswapDetection();

    Optional<Boolean> returnDetailedError();

    Map<String, Map<String, MessageUtilConfiguration>> messageUtilConfigsMap();
    Map<String, MessageUtilConfiguration> messageUtilConfigurations();

    interface MessageUtilConfiguration {
    	Optional<Boolean> enableDataswapDetection();
        //Includes 'default'
        List<MessageUtilInstruction> messageUtilInstructions();

        interface MessageUtilInstruction {
            String name(); //x-correlationId

            String instructionType(); // REQUEST, RESPONSE

            String matchStrategy(); // REQUIRED

            Optional<String> groomAction(); // null, REPLACE

            String location(); //HDR

            String type(); //VALUE

            Optional<String> expression();  //null

            Optional<Boolean> loggable(); //true, false

            Optional<String> errorCode(); //515

            Optional<String> errorMsg(); // x-correlationId is required

            Optional<String> associatedInstruction(); // "x-correlationId" or whatever is in the 'name'
        }

    }
    
}

Associated Snippet from YAML file:

#====================================================================
# Messagehandler config
#====================================================================
message-util-configurations:
  enable-dataswap-detection: true
  message-util-configs-map:
    filter:
      default:
        enable-dataswap-detection: false
      get-jokes-uni:
        enable-dataswap-detection: true
        message-util-instructions:
          - name: x-correlationId
            instruction-type: REQUEST
            match-strategy: REQUIRED
            groom-action: ''
            location: HDR
            type: VALUE
            loggable: true

          - name: x-correlationId
            associated-instruction: x-correlationId
            instruction-type: RESPONSE
            match-strategy: REQUIRED
            groom-action: ''
            location: HDR
            type: VALUE
            loggable: true

    client:
      reaction-api:
        enable-dataswap-detection: true
        message-util-instructions:
          - name: x-correlationId
            instruction-type: REQUEST
            match-strategy: REQUIRED
            groom-action: ''
            location: HDR
            type: VALUE
            loggable: true

          - name: x-correlationId
            associated-instruction: x-correlationId
            instruction-type: RESPONSE
            match-strategy: REQUIRED
            groom-action: ''
            location: HDR
            type: VALUE
            loggable: true

      setup-api:
        enable-dataswap-detection: true
        message-util-instructions:
          - name: x-correlationId
            instruction-type: REQUEST
            match-strategy: REQUIRED
            groom-action: ''
            location: HDR
            type: VALUE
            loggable: true

          - name: x-correlationId
            associated-instruction: x-correlationId
            instruction-type: RESPONSE
            match-strategy: REQUIRED
            groom-action: ''
            location: HDR
            type: VALUE
            loggable: true
@gastaldi
Copy link
Contributor

gastaldi commented Jun 8, 2022

/cc @radcortez

@gastaldi
Copy link
Contributor

gastaldi commented Jun 8, 2022

Seems to be a bug in SmallRye Config. I created a test that reproduces it. I'll try to submit a PR soon

@gastaldi
Copy link
Contributor

gastaldi commented Jun 8, 2022

I found that this commit introduced this bug: smallrye/smallrye-config@c0df101

@gastaldi
Copy link
Contributor

gastaldi commented Jun 9, 2022

I created smallrye/smallrye-config#762 to track this fix in the smallrye-config repo.

@tbkahuna48
Copy link
Author

quick turn around - nice work

@radcortez
Copy link
Member

Fixed in smallrye/smallrye-config#766. Requires an update of SmallRye Config.

@radcortez radcortez self-assigned this Jun 14, 2022
@quarkus-bot quarkus-bot bot added this to the 2.11 - main milestone Jun 15, 2022
@gsmet gsmet modified the milestones: 2.11 - main, 2.10.0.Final Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants