This article explains the maximum length of characters supported while configuring policy names on certain Junos versions that might restrict successful commit operations on Junos series devices.
Configuration Error:
error: key value is too long (253). Maximum supported length is (250) error: statement creation failed: (( "DENY-DEFAULT" && "REMOVE-COMM-ALL" && "ACCEPT-AS99999.99999-ROUTE" && "SET-DENY-TESTE-INTERNAL" && "SET-MED-TEN" && "SET-TYPE-DC" && "SET-LOCALPREF-TESTE" && "SET-SCOPE-WORLD" && "SET-LOCATION" && "SET-AS99999.99999-IN" && "ACCEPT-ANYCAST-ROUTE" ))
Here, the words in black represent the policy name.
This is an expected error since certain releases of Junos have a restricted character length allocated for policy names. The maximum character length is 250 for some releases on the Junos series devices. The following versions have a strict 250 limit on policy names:
Example:
On a device running Junos OS 15.1F5:
user@host# set policy-options policy-statement AS99999-TESTIN-IN term ONE from policy (( DENY-DEFAULT && REMOVE-COMM-ALL && ACCEPT-AS99999.99999-ROUTE && SET-DENY-TESTE-INTERNAL && SET-MED-TEN && SET-TYPE-DC && SET-LOCALPREF-TESTE && SET-SCOPE-WORLD && SET-LOCATION && SET-AS99999.99999-IN && ACCEPT-ANYCAST-ROUTE )) user@host# set policy-options policy-statement AS99999-TESTIN-IN term ONE then accept user@host# set policy-options policy-statement AS99999-TESTIN-IN term TWO then reject
The commit executes successfully even when the policy name exceeds 250 characters. The length of characters is counted after adding double quotes around each name separated by &&. In the above, the characters will be as below:
(( "DENY-DEFAULT" && "REMOVE-COMM-ALL" && "ACCEPT-AS99999.99999-ROUTE" && "SET-DENY-TESTE-INTERNAL" && "SET-MED-TEN" && "SET-TYPE-DC" && "SET-LOCALPREF-TESTE" && "SET-SCOPE-WORLD" && "SET-LOCATION" && "SET-AS99999.99999-IN" && "ACCEPT-ANYCAST-ROUTE" ))
Total character count = 253
[MASTER]
[edit] user@host# commit commit complete
Similarly, on a device running Junos OS 17.4R2:
[edit] user@host# set policy-options policy-statement AS99999-TESTIN-IN term ONE from policy (( DENY-DEFAULT && REMOVE-COMM-ALL && ACCEPT-AS99999.99999-ROUTE && SET-DENY-TESTE-INTERNAL && SET-MED-TEN && SET-TYPE-DC && SET-LOCALPREF-TESTE && SET-SCOPE-WORLD && SET-LOCATION && SET-AS99999.99999-IN && ACCEPT-ANYCAST-ROUTE ))
An error is displayed indicating that the character count exceeds 250.