We have just upgraded from 2.2.4 to 2.2.5 and the following property of a user-provided service on cloudfoundry (PWS in our case) cannot be resolved anymore: Could not resolve placeholder 'vcap.services.elastic.credentials.sslUri' in value "${vcap.services.elastic.credentials.sslUri}"

We use that property in our application-dev.yml.

Since this causes the application startup to fail, we currently cannot upgrade. Is there any workaround?

Comment From: tornaia

I have a similar issue after the same (2.2.4 -> 2.2.5) upgrade with a different provider (Swisscom).

Comment From: dreis2211

@rreitmann & @tornaia I guess this is caused by https://github.com/spring-projects/spring-boot/commit/544dca7f1b8a2adf7921f7c56b86f7abb8f37964 respectively #18915 . I would try wrapping sslUri with []. E.g. ${vcap.services.elastic.credentials[sslUri]} - at least until the Spring Boot team has a better recommendation/fix.

Comment From: rreitmann

@dreis2211 Your workaround works for me! Thanks a lot and I think that this really demonstrates the power :muscle: of the spring boot community :smile:

IMHO someone should adjust the documentation of CloudFoundryVcapEnvironmentPostProcessor in case this change has been intended...

Comment From: dreis2211

@rreitmann Glad this works for you. In case this wasn't intended, I'm also happy to provide a fix for it and allowing uppercase keys again.

Comment From: tornaia

Thank you @rreitmann and @dreis2211! The suggested workaround works very well! ❤️😄

Comment From: cweberruss

Thanks @dreis2211 the suggested workaround also helps in case of underscores, even with the dot before the brackets!

My case: @Value("${vcap.services.backend-authentication.credentials.[key_password]}")

Comment From: jabouchleih

As mentioned in #20364, @ConfigurationProperties also seem to be broken. Wrapped properties are not automatically mapped to the fields inside the @ConfigurationProperties-annotated class:

vcap.services.asdcs-document-db.credentials.[ca_cert] = https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
vcap.services.asdcs-document-db.credentials.[instance_identifier] = d1234567890-12345671-12351
vcap.services.asdcs-document-db.credentials.[reader-endpoint] =  docdb-with-identifier-reader.eu-west-1.docdb.amazonaws.com

results in:

@Configuration
@ConfigurationProperties("vcap.services.asdcs-document-db.credentials")
public class CloudFoundryAwsDocumentDbCredentials {

  String caCert; // is null
  String instanceIdentifier; //is null
  ...
  String readerEndpoint; //is null
  ...
}

Comment From: wilkinsona

We're going to revert https://github.com/spring-projects/spring-boot/commit/544dca7f1b8a2adf7921f7c56b86f7abb8f37964.

Comment From: deiveehan

I face a similar issue, I am not able to bind my creds to the application.yml, I upgraded my spring boot version to 2.2.6-RELEASE, still same problem, is this issue fixed ?

Comment From: deiveehan

gradle file: id 'org.springframework.boot' version '2.2.6.RELEASE'

application.yml

storage:
  credentials:
    encoded-key: ${vcap.services.google-storage.credentials.[privateKeyData]}
  project-id: <project name>

Error I get in the console.

     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     ... 27 common frames omitted
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.cloud.storage.Storage]: Factory method 'storage' threw exception; nested exception is java.lang.IllegalArgumentException: Illegal base64 character 24
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     ... 52 common frames omitted
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT Caused by: java.lang.IllegalArgumentException: Illegal base64 character 24
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     at java.util.Base64$Decoder.decode0(Base64.java:714) ~[na:1.8.0_232]
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     at java.util.Base64$Decoder.decode(Base64.java:526) ~[na:1.8.0_232]
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     at java.util.Base64$Decoder.decode(Base64.java:549) ~[na:1.8.0_232]
   2020-04-01T06:31:07.78-0400 [APP/PROC/WEB/0] OUT     at org.springframework.cloud.gcp.core.DefaultCredentialsProvider.<init>(DefaultCredentialsProvider.java:100) ~[spring-cloud-gcp-core-1.2.0.RELEASE.jar:1.2.0.RELEASE]

Comment From: deiveehan

Please confirm if this is fixed in the latest version of spring boot / which version of spring boot to be used to fix this

Comment From: wilkinsona

@deiveehan This problem was specific to the consumption of properties that are provided by the VCAP_SERVICES environment variable. Credentials configured via application.yml are not affected.

Comment From: deiveehan

I am able to get it to to work after I added spring cloud starter cloud foundry into my gradle build which helpe me in injecting the vcap services of google storage to the spring cloud GCP.

Refer: https://github.com/spring-cloud/spring-cloud-gcp/issues/2297