Relay Affiliation Code not Working

We have been running the following relay affiliation code for a long time and it just recently stopped working. I am trying to figure out why. Every time it runs, it errors with: Error: Singular expression refers to nonexistent object.

The format of the subnetmap.txt file is as follows. We only use subnet and city name.

172.29.50.50/24 City name City State Country Region Address Client.

( if (number of elements of it = 0) then ("HeadRelay;*") else concatenation ";" of (elements of it)) of set of /* 
Prepare Affiliation String */ ( preceding text of last ";" of ( (if(exists item 0 of it AND item 0 of it != "" ) then 
(item 0 of it & ";") else "") /* & (if(exists item 2 of it AND item 2 of it != "" AND item 6 of it is contained by 
"state,country,region,all relays" ) then (item 2 of it & ";") else "") & (if(exists item 3 of it AND item 3 of it != "" 
AND item 6 of it is contained by "country,region,all relays") then (item 3 of it & ";") else "") & (if(exists item 4 
of it AND item 4 of it != "" AND item 6 of it is contained by "region,all relays") then (item 4 of it & ";") else "") 
& (if(exists item 6 of it AND item 6 of it = "headend") then ("HeadRelay" & ";") else "") */ )) of /* Disect Line 
From SubnetMap.txt */ ( /* Location Code - item 0 */ preceding text of first "%09" of it, /* City Code - item 1 */ 
preceding text of first "%09" of following text of first "%09" of it, /* State - item 2 */ preceding text of first 
"%09" of following text of first "%09" of following text of first "%09" of it, /* Country - item 3 */ preceding text 
of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of it, 
/* Region - item 4 */ preceding text of first "%09" of following text of first "%09" of following text of first "%09" 
of following text of first "%09"of following text of first "%09" of it, /* Address - item 5 */ preceding text of first 
"%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of following 
text of first "%09" of following text of first "%09" of it, /* FailOverFlag item 6 */ following text of first "%09" of 
following text of first "%09" of following text of first "%09" of following text of first "%09" of following text of 
first "%09" of following text of first "%09" of it ) of /* Remove Duplicates */ (elements of set of it) of /* 
Compare Subnets Of Network Adapters To SubnetMap.txt */ ( following texts of firsts "||" of unique values of 
( (bit (preceding text of first "%09" of it as integer)) of item 2 of it as string & "||" & following text of first "%09" 
of item 2 of it) of ( ( first (following text of first "/" of it as integer) of item 0 of it, first (following text of first "/" of 
it as integer) of item 1 of it, item 2 of it ) of ( (item 0 of it & "/" & following text of first "/" of preceding text of 
first "%09" of item 1 of it) , ( ( concatenation of (last 8 of ("00000000" & (it as integer) as bits as string)) of 
substrings separated by "." of it) of preceding text of first "/" of item 1 of it & "/" & following text of first "/" of 
preceding text of first "%09" of item 1 of it ) , (following text of first "/" of item 1 of it) ) of ( ( ( ( concatenations 
of (last 8 of ("00000000" & (it as integer) as bits as string)) of substrings separated by "." of it) ) of (( ( 
addresses whose (it as string != "0.0.0.0") of ip interfaces whose (loopback of it = false) of network ) as 
string ) ) ) , ( lines whose ( (it = regex "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/[[:digit:]]+[[:blank:]].* 
[[:blank:]].*") AND (it contains "%09") ) of (file "SubnetMap.txt" of client folder of site whose (name of it = 
"RelayAffiliation")) ) ) ) whose (item 0 of it = item 1 of it) ) & ";HeadRelay"

Nice one! First suggestion - check to see if you have something strange in your SubnetMap.txt

Error: Singular expression refers to nonexistent object. You have asked for a singular but there are None of these. Solution is usually to pluralize or trap the non-existence.

Check this relevance first:
exists file "SubnetMap.txt" of client folder of site whose (name of it = "RelayAffiliation")

Next check is for the lines in the file with the regex. Although this is plural, so probably not the issue.

( lines whose ( (it = regex "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+/[[:digit:]]+[[:blank:]].* [[:blank:]].*") AND (it contains "%09") ) of (file "SubnetMap.txt" of client folder of site whose (name of it = "RelayAffiliation")) )

next check for the Addresses converted into Bits (also probably not the issue - it’s plural already)

( ( concatenations of (last 8 of ("00000000" & (it as integer) as bits as string)) of substrings separated by "." of it) ) of (( ( addresses whose (it as string != "0.0.0.0") of ip interfaces whose (loopback of it = false) of network ) as string ) )

Ah… this section tears apart the lines in the file… and has lots of singulars… I bet your file as some missing Tabs on some lines… note that this one will not execute in debugger by itself because the It is part of an earlier phrase.

( /* Location Code - item 0 */ preceding text of first "%09" of it, /* City Code - item 1 */ preceding text of first "%09" of following text of first "%09" of it, /* State - item 2 */ preceding text of first "%09" of following text of first "%09" of following text of first "%09" of it, /* Country - item 3 */ preceding text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of it, /* Region - item 4 */ preceding text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09"of following text of first "%09" of it, /* Address - item 5 */ preceding text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of it, /* FailOverFlag item 6 */ following text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of following text of first "%09" of it )

RECOMMEND: Open SubnetMap.txt in excel, which should see the %09 separators as columns… Then search for blanks in columns and fix the blanks.

1 Like

It was the subnetmap.txt that was the problem. I used Ultraedit to view the file with invisible characters, and I could see that some of the lines had spaces where they should not be, for example:

172.29.45.45.0 / 24 instead of 172.29.45.45.0/24 Also, there were a couple of subnets with a single space at the end.

I am glad I was able to figure it out because it would have taken me a month to figure out the code, if I ever would.

Thanks for the reply brolly33. You may recognize the code.

6 Likes