TWSD-1350 Not displaying the list of interfaces when the interface name is modified with special characters especially like this format port1(data_

Review Request #1264 — Created Dec. 24, 2025 and updated

lucille
APV10
rel_apv_10_7_3
TWSD-1350
austin, shuinvy

The WebUI list page fails to display interface names that contain special characters

Root Cause

When SystemInterface or BondInterface interface names contain regular expression special characters (such as parentheses (, periods ., etc.), it causes 500 errors during DelayedQuery processing.

Specific Cause:
1. In the _get_management method, interface names are directly inserted into regular expressions
2. When interface name is "port1(Data_", the generated regular expression becomes:
interface management "port1(Data_" (?P<gateway_ip_str>[0-9|a-f|A-F|:|\.]+)
3. The parenthesis ( is a special character for grouping syntax in regular expressions, causing regex syntax errors
4. The error occurs during the DelayedQuery processing phase of GET requests, not during UPDATE operations

Solution

Use the re.escape() function to escape interface names for regular expressions in both _get_management methods.

Modified Locations:

1. SystemInterface._get_management (Line 537)

@QueryingFields(['manage_port','gateway_ipv4', 'gateway_ipv6'])
def _get_management(self, pk_dict):
    self.cli.set_enable()
    result = self.cli.cmd('show management',
                          RegexParser('interface management "%s" (?P<gateway_ip_str>[0-9|a-f|A-F|:|\.]+)' % re.escape(pk_dict['name']), MATCHALL)
                          )
    # ... rest of the code remains unchanged

2. BondInterface._get_management (Line 707)

@QueryingFields(['manage_port','gateway_ipv4', 'gateway_ipv6'])
def _get_management(self, pk_dict):
    self.cli.set_enable()
    result = self.cli.cmd('show management',
                          RegexParser('interface management "%s" (?P<gateway_ip_str>[0-9|a-f|A-F|:|\.]+)' % re.escape(pk_dict['name']), MATCHALL)
                          )
    # ... rest of the code remains unchanged

Modification Effect:
- Original: "port1(Data_" → Regular expression: "port1(Data_"
- After escaping: "port1(Data_" → Regular expression: "port1\\(Data_"

Verification

Test Steps:
1. Create interface names containing special characters, such as: "port1(Data_"
2. Access SystemInterface or BondInterface list pages via Web UI or REST API
3. Confirm that 500 errors no longer occur
4. Verify that interface names with special characters properly display management interface related fields

Expected Results:
- ✅ No more 500 Internal Server Error
- ✅ Interface names with special characters are handled properly
- ✅ manage_port, gateway_ipv4, gateway_ipv6 fields display correctly
- ✅ Interface names without special characters remain unaffected

Test Coverage:
- Interface names containing: ()[]{}.*+?^$| and other regex special characters
- Both SystemInterface and BondInterface classes
- GET request DelayedQuery processing flow

Loading...