Handling of $$ in value
The current handling will replace $$ in a value with a single $ - this is due to the internal escaping behavior, which escapes escapes $ as $$. However this behavior isn't documented and can be surprising to users. Should https://github.com/smallrye/smallrye-config/blob/5a96de2849c87d144586df07dd4529e28d7e3b85/implementation/src/main/java/io/smallrye/config/ExpressionConfigSourceInterceptor.java#L101 also account for $$, or should this behavior be documented?
I don't mind submitting a patch if it's the former.
The $$ is indeed used as an escape sequence to not expand on expressions.
That particular piece is yet another rule added by MP Config, in which \$ should act as an escape sequence for expressions. Please check https://github.com/smallrye/smallrye-config/issues/746 for more context.
I believe the expression code blindly escapes expressions with the double $, because there is a flag that can be used to omit the brackets and treat the value as an expression. At this stage, we are never going to turn that flag on, so maybe we can make the escape smarter and only work if square brackets are found after?
We are currently facing this issue, we receive our DB password through an AWS secret and there's a password rotation and every now and then we have a password that contains $$ which is replaced by $ which makes our connection to DB fail.
Everything is automated so we can't escape the $$.
There's no available configuration to change this behaviour since the $$ is replaced even before it's compiled in the ExpressionConfigSourceInterceptor.java:
Expression expression = Expression.compile(escapeDollarIfExists(configValue.getValue()), LENIENT_SYNTAX, NO_TRIM, NO_SMART_BRACES, DOUBLE_COLON);
https://github.com/smallrye/smallrye-config/blob/main/implementation/src/main/java/io/smallrye/config/ExpressionConfigSourceInterceptor.java
Is there any hope this behaviour will change in the future?
I see this issue is quite old, should I open a new one?