JSON Variable Replacement suddenly fails

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

value - some URL

it doesn’t replace it at all :confused:

Hi @frantisek.pernicka

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:

key - yarp:clusters:InsuranceAPI:Destinations:InsuranceAPI:destination1:Address

This should allow you to correctly target the “Address” property.

Let me know if this works for you!
Kind Regards
Sean

Hi,

I tried it out but with no success, when I used : instead of / it also doesn’t work. I also tried to put

“InsuranceAPI/destination1”: {
“Address”: “some URL”
}

into value but also didn’t get replaced.

I wonder, was there any update how json is replaced by Octopus bc it was working fine until last Friday :confused:

P.S: the path with / I need to have bc it’s done in this way in YARP (Microsoft Proxy Gateway)

Hi @frantisek.pernicka

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)?

Kind Regard
Sean

thanks for reply,

we r using Octopus Cloud,
instance: sator-it.octopus.app
version: 2023.1.4670-hotfix.6549

i tried it in this way:
key: yarp:clusters:SerializationApi:Destinations
value: {“SerializationApi/destination1”:{“Address”:“https://some url”}}

and in appsettings.jon I have:
“yarp”: {
“SerializationApi”: {
“Destinations”: {}

    },

}
(I also tried to have Destinations: (without { } ) but no success either.

Hi Frantisek,

Thanks for the update and details! I’ll jump in for Sean as he’s currently offline as part of our UK-based team. :slight_smile:

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. :slight_smile:

Best regards,

Kenny

ok, I found the issue.

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” :slight_smile:

2 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.