Since today, we are having issue with variable replacement in JSON.
Simple replacement like
{“something”:“variable”} works fine, however, when it gets more hierarchical, it doesn’t replace.
e.g.
in appsetting.json we have
“yarp”:
{
“InsuranceAPI”: {
“Destinations”: {
“InsuranceAPI/destination1”: {
“Address”: “some URL”
}
}
},
}
in Octopus variable we have:
key - yarp:clusters:InsuranceAPI:Destinations:InsuranceAPI/destination1:Address
I would assume it is an issue with the forward slash in your “InsuranceAPI/destination1” property. I would guess the selector gets confused between using the colon and the slash. The slash is used for XPATH where the colons is another type of selector (I forgot the name, apologies!).
In this case, I would recommend having “InsuranceAPI” as one property, then step down into that with “destintation1” so you can add more inside there. Your selector would then be similar, but without the forward slash:
I apologise the late reply. My email only just notified me that you replied. Sorry!
If you need the forward slash in the path, that might cause some issues and maybe a replacement will need to be done on that whole part. I can see that you tried to do that and it didn’t work correctly though, which is odd.
Could you share how you are calling the replacement in your project?
Since you were saying it was working fine until last Friday, have you had any updates to your Octopus instance? Are you using on-premise or our cloud infrastructure? If you are cloud, can you let me know the instance URL so I can check this on our side?
Could you also let me know the version as well (if you’re on cloud I can check this through your instance)?
Thanks for the update and details! I’ll jump in for Sean as he’s currently offline as part of our UK-based team.
I ran through a test mimicking your original details exactly (your json file contents and Octopus variable) and I noticed the clusters in the variable name doesn’t map to the json contents. In that exact case, removing that from the variable name did allow the variable value to be replaced into the Address (otherwise it didn’t do any replacement for this variable).
E.g. my variable ended up looking like this: yarp:InsuranceAPI:Destinations:InsuranceAPI/destination1:Address
Let me know what you think, or if I’m off the mark in some way.
Your response lead me to the issue - some of other developers modified appsettings and wrongly put closing } so it moved node clusters out of yarp parent. Moving it back work as usual before.
Thank you and we can close this issue as a “problem between keyboard and chair”