spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

YAML: Spring Boot Escape sequence not working

Open ddg-igh opened this issue 5 years ago • 2 comments

When using a yaml with the spring boot escape sequence of "[key.with.dots]" the conversion will not work and an invalid key exception will be thrown. The Environment Controller expects in between the "[]" a digit index.

Im using spring-cloud-config-server version 2.2.2.RELEASE.

For example this yaml:

webservices:
    "[domain.test:8080]":
        -   username: me
            password: mypassword

throws

java.lang.IllegalArgumentException: Invalid key: webservices[domain.test:8080][0].password
	at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.getIndex(EnvironmentController.java:457)
	at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.setListValue(EnvironmentController.java:418)
	at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.setMapValue(EnvironmentController.java:409)
	at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.access$100(EnvironmentController.java:366)
	at org.springframework.cloud.config.server.environment.EnvironmentController.convertToMap(EnvironmentController.java:256)
	at org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(EnvironmentController.java:219)
	at org.springframework.cloud.config.server.environment.EnvironmentController.yaml(EnvironmentController.java:208)

ddg-igh avatar Apr 20 '20 07:04 ddg-igh

Is there any plan to fix an issue? I am facing the same issue with gateway CORS config.

spring:
  cloud:
    gateway:
      globalcors:
        cors-configurations:
          '[/*/admin/**]':
            allowedOriginPatterns:
              - "https://*.domain.com"
            allowedOrigins:
              - "http://localhost:4200"
            allowedHeaders: "*"
            allowedMethods: "*"
            maxAge: 1728000

Error:

java.lang.IllegalArgumentException: Invalid key: spring.cloud.gateway.globalcors.cors-configurations[/*/admin/**].allowedOrigins[0]]

leebake avatar Feb 24 '21 10:02 leebake

We will try and get to it for the next service release

ryanjbaxter avatar Feb 24 '21 21:02 ryanjbaxter