Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@
logger = get_logger(__name__)


def _sanitize_log_file(log_obj):
# Convert log object to dict
result = log_obj.as_dict()

# Flatten properties from nested structure and reshape to legacy format
if 'properties' in result and isinstance(result['properties'], dict):
properties = result.pop('properties')
# Extract type from properties and rename to typePropertiesType
if 'createdTime' in properties:
del properties['createdTime'] # Remove createdTime as it's not in the original SDK model
if 'type' in properties:
result['typePropertiesType'] = properties.pop('type')
# Merge remaining properties into root level
result.update(properties)

# Add systemData if not present (for backward compatibility)
if 'systemData' not in result:
result['systemData'] = None
Comment on lines +37 to +39
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding systemData (even as None) changes the command output shape for consumers that were previously on the older SDK (where this field did not exist). If the intent is to preserve the legacy contract, it’s safer to omit systemData from the returned dict (and potentially strip it when present) rather than always introducing the key.

Suggested change
# Add systemData if not present (for backward compatibility)
if 'systemData' not in result:
result['systemData'] = None
# Remove systemData to preserve the legacy output contract
result.pop('systemData', None)

Copilot uses AI. Check for mistakes.

return result


def flexible_server_download_log_files(client, resource_group_name, server_name, file_name):
validate_resource_group(resource_group_name)

Expand Down Expand Up @@ -50,8 +72,7 @@ def flexible_server_list_log_files_with_filter(client, resource_group_name, serv
if max_file_size is not None and f.size_in_kb > max_file_size:
continue

del f.created_time
files.append(f)
files.append(_sanitize_log_file(f))

return files

Expand All @@ -75,8 +96,7 @@ def flexible_server_log_list(client, resource_group_name, server_name, filename_
if max_file_size is not None and f.size_in_kb > max_file_size:
continue

del f.created_time
files.append(f)
files.append(_sanitize_log_file(f))

return files

Expand Down
Loading
Loading