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)

Comment From: leebake

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]]

Comment From: ryanjbaxter

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