Skip to content

[PostgreSQL] az postgres flexible-server server-logs list: Fix 33090, command crashes with an AttributeError when listing log files#33096

Open
nachoalonsoportillo wants to merge 6 commits intoAzure:devfrom
nachoalonsoportillo:fix-breaking-change-introduced-with-latest-SDK
Open

[PostgreSQL] az postgres flexible-server server-logs list: Fix 33090, command crashes with an AttributeError when listing log files#33096
nachoalonsoportillo wants to merge 6 commits intoAzure:devfrom
nachoalonsoportillo:fix-breaking-change-introduced-with-latest-SDK

Conversation

@nachoalonsoportillo
Copy link
Copy Markdown
Member

@nachoalonsoportillo nachoalonsoportillo commented Mar 28, 2026

Related command

Description
az postgres flexible-server server-logs list crashes with an AttributeError when listing log files.

File ".../azure/cli/command_modules/postgresql/flexible_server_custom_postgres.py", line 1317, in flexible_server_list_log_files_with_filter
    del f.created_time
        ^^^^^^^^^^^^^^
AttributeError: 'CapturedLog' object has no attribute 'created_time'

Here are the significant differences between LogFile (old) and CapturedLog (new):

Field changes

Aspect LogFile (old) CapturedLog (new)
Class name LogFile CapturedLog
type field name type_properties_type (renamed to avoid collision with ARM's type) type (inside CapturedLogProperties)
type values Undocumented free string Documented: 'ServerLogs' or 'UpgradeLogs'
system_data Absent Present (ARM createdBy/modifiedBy metadata)
Properties nesting Flat on the model Nested in CapturedLogProperties, flattened via __flattened_items

Read-only enforcement
In the old SDK, created_time and last_modified_time were declared readonly: True in _validation — i.e., server-side only. In the new SDK, both are declared with full CRUD visibility (["read", "create", "update", "delete", "query"]), removing the hard read-only constraint at the SDK layer.

SDK generation style
The old SDK was AutoRest-generated (_serialization.Model, _validation, _attribute_map dicts). The new SDK uses the Python Code Generator (_Model, rest_field, @overload constructors). This changes how serialization and validation are expressed, though the wire format is the same.

For now, let's fix it like this. My proposal is to also add a deprecation note to inform that shape of returned object will change in the future to, at least, surface createdTime. We could also consider renaming typePropertiestype to something like logType.

Testing Guide
I noticed that the existing tests weren't running the `server-logs list' command when live test was run. That would have caught the error before we would have merged the PR that introduced the offending SDK. So, I've enable it and refreshed the recordings.

History Notes

[PostgreSQL] az postgres flexible-server server-logs list: Fix 33090, command crashes with an AttributeError when listing log files


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings March 28, 2026 19:08
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 28, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @nachoalonsoportillo,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 28, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Mar 28, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@nachoalonsoportillo
Copy link
Copy Markdown
Member Author

Fixes #33090.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the PostgreSQL flexible-server server logs listing implementation to sanitize captured log file objects before returning them, specifically to remove created_time-related fields that are causing SDK compatibility issues.

Changes:

  • Added _sanitize_log_file() helper to convert log file objects into dictionaries and recursively remove created_time variants.
  • Updated flexible_server_list_log_files_with_filter and flexible_server_log_list to return sanitized log file dictionaries instead of mutating SDK objects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nachoalonsoportillo nachoalonsoportillo changed the title [PostgreSQL] Sanitize log file objects to ensure SDK compatibility by… [PostgreSQL] az postgres flexible-server server-logs list: BUG FIX, command crashes with an AttributeError when listing log files Mar 28, 2026
…og file generation wait logic

- Removed the conditional return for live tests.
- Combined the environment variable check with the sleep function to streamline the waiting period for log file generation.
@nasc17
Copy link
Copy Markdown
Member

nasc17 commented Mar 30, 2026

@calvinhzy and @yonzhan please trigger checks

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Mar 31, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@nachoalonsoportillo nachoalonsoportillo changed the title [PostgreSQL] az postgres flexible-server server-logs list: BUG FIX, command crashes with an AttributeError when listing log files [PostgreSQL] az postgres flexible-server server-logs list: Fix 33090, command crashes with an AttributeError when listing log files Mar 31, 2026
@nasc17
Copy link
Copy Markdown
Member

nasc17 commented Mar 31, 2026

@calvinhzy and @yonzhan please trigger checks, fix we put in for the title, and we needed this for the April release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants