You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/10/28 03:14:18 UTC

[GitHub] [skywalking] zhyyu opened a new issue #8029: [Bug] config env placeholder yaml parse error

zhyyu opened a new issue #8029:
URL: https://github.com/apache/skywalking/issues/8029


   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Apache SkyWalking Component
   
   OAP server (apache/skywalking)
   
   ### What happened
   
   I use `SW_ES_PASSWORD` env to inject es password, the pwd contain special character like `!AI!3B`.  And when I start the OAP, it occurs error, and fail start up.
   
   ```
   2021-10-28 10:57:55,024 - org.apache.skywalking.oap.server.starter.OAPServerBootstrap - 61 [main] ERROR [] - while parsing a node
    in 'string', line 1, column 1:
       !AI!3B
       ^
   found undefined tag handle !AI!
    in 'string', line 1, column 1:
       !AI!3B
       ^
   
   org.yaml.snakeyaml.parser.ParserException: while parsing a node
    in 'string', line 1, column 1:
       !AI!3B
       ^
   found undefined tag handle !AI!
    in 'string', line 1, column 1:
       !AI!3B
       ^
   
   	at org.yaml.snakeyaml.parser.ParserImpl.parseNode(ParserImpl.java:411) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.parser.ParserImpl.access$1300(ParserImpl.java:116) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockNode.produce(ParserImpl.java:358) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:157) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:147) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:133) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:505) ~[snakeyaml-1.18.jar:?]
   	at org.yaml.snakeyaml.Yaml.load(Yaml.java:424) ~[snakeyaml-1.18.jar:?]
   	at org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader.replacePropertyAndLog(ApplicationConfigLoader.java:122) ~[classes/:?]
   	at org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader.lambda$null$1(ApplicationConfigLoader.java:93) ~[classes/:?]
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[?:1.8.0_282]
   	at org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader.lambda$null$2(ApplicationConfigLoader.java:83) ~[classes/:?]
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[?:1.8.0_282]
   	at org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader.lambda$loadConfig$3(ApplicationConfigLoader.java:75) ~[classes/:?]
   	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[?:1.8.0_282]
   	at org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader.loadConfig(ApplicationConfigLoader.java:70) ~[classes/:?]
   	at org.apache.skywalking.oap.server.starter.config.ApplicationConfigLoader.load(ApplicationConfigLoader.java:52) ~[classes/:?]
   	at org.apache.skywalking.oap.server.starter.OAPServerBootstrap.start(OAPServerBootstrap.java:46) [classes/:?]
   	at org.apache.skywalking.oap.server.starter.OAPServerStartUp.main(OAPServerStartUp.java:27) [classes/:?]
   
   ```
   
   ### What you expected to happen
   
   Config can inject env which contain special character(like !), and start up successfully.
   
   ### How to reproduce
   
   Set `SW_ES_PASSWORD` env to some special string like `!AI!3B`, and start up the OAP, then it will occur yaml parse node error.
   
   ### Anything else
   
   I checked the code and found in `ApplicationConfigLoader` class
   
   ```java
   private void replacePropertyAndLog(final Object propertyName, final Object propertyValue, final Properties target,
                                          final Object providerName) {
           final String valueString = PropertyPlaceholderHelper.INSTANCE
               .replacePlaceholders(propertyValue + "", target);
           if (valueString != null) {
               if (valueString.trim().length() == 0) {
                   target.replace(propertyName, valueString);
                   log.info("Provider={} config={} has been set as an empty string", providerName, propertyName);
               } else {
                   // Use YAML to do data type conversion.
                   final Object replaceValue = yaml.load(valueString);
                   if (replaceValue != null) {
                       target.replace(propertyName, replaceValue);
                       log.info(
                           "Provider={} config={} has been set as {}",
                           providerName,
                           propertyName,
                           replaceValue.toString()
                       );
                   }
               }
           }
       }
   ```
   
   the line `final Object replaceValue = yaml.load(valueString);` lead this error, when valuesString contains some special character like (!), yaml parse error.
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng closed issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #8029:
URL: https://github.com/apache/skywalking/issues/8029


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zhyyu commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
zhyyu commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954558949


   > If I don't misunderstand your case, your problem can be resolved by quoting you password like `"!A1B2"`, did you try that?
   
   I tried just now, it worked. But the problem is that password env is injected by the ops team, my team can not change it...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-953466760


   Are you going to propose a fix for this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954575195


   > > If I don't misunderstand your case, your problem can be resolved by quoting you password like `"!A1B2"`, did you try that?
   > 
   > I tried just now, it worked. But the problem is that password env is injected by the ops team, my team can not change it...
   
   Shouldn't ask ops team to change is a better way?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zhyyu removed a comment on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
zhyyu removed a comment on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954548067


   Tried just now, `SW_ES_PASSWORD='"!AI!3B"' export SW_ES_PASSWORD`, still error.
   ```
   private String getConfigValue(String key, final Properties properties) {
           String value = System.getProperty(key);
           if (value == null) {
               value = System.getenv(key);
           }
           if (value == null) {
               value = properties.getProperty(key);
           }
           return value;
       }
   ```
   
   `System.getenv(key);` will return `AI!3B`  without quote.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954582167


   > while the ops don't only serve my team.. the other team also get the password from the env, and if ops add quote in the password, the other team do not parse it by yaml, they will think the password contain quote, then there will be wrong.
   
   OK, make sense to enhance. But we need a UT to prove the new codes work in this case. Please add it. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-953468418


   Assigned to yourself. Wait for your pull request. Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zhyyu commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
zhyyu commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954548067


   Tried just now, `SW_ES_PASSWORD='"!AI!3B"' export SW_ES_PASSWORD`, still error.
   ```
   private String getConfigValue(String key, final Properties properties) {
           String value = System.getProperty(key);
           if (value == null) {
               value = System.getenv(key);
           }
           if (value == null) {
               value = properties.getProperty(key);
           }
           return value;
       }
   ```
   
   `System.getenv(key);` will return `AI!3B`  without quote.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zhyyu commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
zhyyu commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954584082


   > > while the ops don't only serve my team.. the other team also get the password from the env, and if ops add quote in the password, the other team do not parse it by yaml, they will think the password contain quote, then there will be wrong.
   > 
   > OK, make sense to enhance. But we need a UT to prove the new codes work in this case. Please add it.
   
   ok, I am adding.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zhyyu commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
zhyyu commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954580656


   while the ops don't only serve my team.. the other team also get the password from the env, and if ops add quote in the password, the other team do not parse it by yaml, they will think the password contain quote, then there will be wrong.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] kezhenxu94 commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-954513957


   If I don't misunderstand your case, your problem can be resolved by quoting you password like `"!A1B2"`, did you try that?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] zhyyu commented on issue #8029: [Bug] config env placeholder yaml parse error

Posted by GitBox <gi...@apache.org>.
zhyyu commented on issue #8029:
URL: https://github.com/apache/skywalking/issues/8029#issuecomment-953467643


   > Are you going to propose a fix for this?
   
   Yes, I am willing to do it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org