Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Some tokens aren't replaced #149

Closed
dmytro-aleinykov opened this issue Apr 16, 2020 · 13 comments
Closed

Some tokens aren't replaced #149

dmytro-aleinykov opened this issue Apr 16, 2020 · 13 comments

Comments

@dmytro-aleinykov
Copy link

dmytro-aleinykov commented Apr 16, 2020

Hello, we're experiencing some strange issue with this Task. It was perfectly working earlier, till yesterday.

For some reason, it does not replace some tokens. It looks like we've found a common pattern: it doesn't replace a token, when one line above is this symbol "{" with tailing spaces.

Example:
tokentobereplaced = cool-value

***
some text
{
some text {tokentobereplaced}
some text {tokentobereplaced}
***

Expected result:

***
some text
{
some text cool-value
some text cool-value
***

Actual result

***
some text
{
some text {tokentobereplaced}
some text cool-value
***
@qetza
Copy link
Owner

qetza commented Apr 16, 2020

Hi @dmytro-aleinykov,
There was an update wednesday to support spaces between the token prefix/suffix and the variable name.
It seems your issue is a side effect of this change because your token prefix is also used as a normal character in your file. I will investigate an deploy a fix ASAP or revert the feature if i cannot find a fix.

@dmytro-aleinykov
Copy link
Author

Hi @qetza,
Thanks for so fast reply. We'd be glad to see this fixed :)
We do like the extension and we use it in lots of our pipelines.

@qetza
Copy link
Owner

qetza commented Apr 16, 2020

Fix is done and deployed in version 3.5.2

@dmytro-aleinykov
Copy link
Author

dmytro-aleinykov commented Apr 16, 2020

Hi again.
Thank you very much for the quick fix.
I've just tested it. It looks like, almost all issues with replacing have gone.

However, there are still some :(
I'll give you more details a little bit later today, probably in a couple of hours

@qetza
Copy link
Owner

qetza commented Apr 16, 2020

Ok, i’ll wait for your repro steps

@dmytro-aleinykov
Copy link
Author

dmytro-aleinykov commented Apr 17, 2020

Hi @qetza ,
Sorry for the late reply.
As I see, it does replacements in places where it shouldn't do any, so it corrupts config files.

Here is an example:
IN FILE
"sshd" : {
"port" : 1234
},

OUT FILE:
"sshd" : ,

EXPECTED RESULT: no changes
"sshd" : {
"port" : 1234
},

Here is the warning, which I see in logs:
##[warning] variable not found: "port" : 1234

One more example:

IN FILE:
firewallMode = somevalue
inboundConfig {
listeningAddress = "0.0.0.0:xxxx"
}

floatOuterConfig {
variable1 = "{VALUE_TO_REPLACE_1}:12005"
variable2 = "{VALUE_TO_REPLACE_2}"
tunnelSSLConfiguration {
variable3 = "{VALUE_TO_REPLACE_3}"
}
}

OUT FILE:
firewallMode = somevalue
inboundConfig
floatOuterConfig {
variable1 = "replaced_correctly_1:12005"
variable2 = "{replaced_correctly_2}"
tunnelSSLConfiguration {
variable3 = "{replaced_correctly_2}"
}
}

EXPECTED RESULT:
firewallMode = somevalue
inboundConfig {
listeningAddress = "0.0.0.0:xxxx"
}

floatOuterConfig {
variable1 = "replaced_correctly_1:12005"
variable2 = "{replaced_correctly_2}"
tunnelSSLConfiguration {
variable3 = "{replaced_correctly_2}"
}
}

@qetza
Copy link
Owner

qetza commented Apr 17, 2020

Ok, the issue is because you are using as token prefix and suffix characters that exists in your file also.
I will release a new version allowing to disable whitespace support. This will allow you to revert to the old code.

@qetza
Copy link
Owner

qetza commented Apr 17, 2020

@dmytro-aleinykov,
One workaround for now could be to check the keep token parameter and set action on missing variable to silently continue.
This will make the task keep the token when no variable is found and not displaying warning in the logs but if you miss a variable you will no be warned.

@qetza
Copy link
Owner

qetza commented Apr 17, 2020

Version 3.6.0 is released with the Use legacy pattern parameter in the Advanced section. Check this parameter to force the task to use the old pattern (do not ignore whitespaces).
This should resolve all your issues.

@qetza
Copy link
Owner

qetza commented Apr 22, 2020

Hi @dmytro-aleinykov,
Is your issue resolved with the latest release?

@finkinfridom
Copy link

@qetza we updated your task to latest version and unfortunately I think the original issue didn't disappear (even with the use legacy pattern checkbox).
at the moment, if I have something similar to this
Serilog__LogMinimumLevel: "__Serilog__LogMinimumLevel__"

both the legacy and the new regexp are not able to properly handle the above scenario (quite standard in netcore appsettings based configurations)

Any help would be appreciated.
Thanks

@qetza
Copy link
Owner

qetza commented Apr 27, 2020

Hi @finkinfridom,
Could you share some diagnostics logs of the task (check diagnostics logs when running the pipeline)? This would allow me to see all your task settings and how it executed as this should be working (provided you customized the token prefix and suffix to __)

@qetza
Copy link
Owner

qetza commented Dec 12, 2021

Closing for long inactivity, feel free to reopen if needed.

@qetza qetza closed this as completed Dec 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants