[PostgreSQL] az postgres flexible-server server-logs list: Fix 33090, command crashes with an AttributeError when listing log files#33096
Conversation
… removing created_time attributes
️✔️AzureCLI-FullTest
|
|
Hi @nachoalonsoportillo, |
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Fixes #33090. |
There was a problem hiding this comment.
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 removecreated_timevariants. - Updated
flexible_server_list_log_files_with_filterandflexible_server_log_listto return sanitized log file dictionaries instead of mutating SDK objects.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/azure-cli/azure/cli/command_modules/postgresql/commands/server_logs_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/postgresql/commands/server_logs_commands.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/postgresql/commands/server_logs_commands.py
Show resolved
Hide resolved
az postgres flexible-server server-logs list: BUG FIX, command crashes with an AttributeError when listing log files
…jects for SDK compatibility
…es for SDK compatibility
…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.
|
@calvinhzy and @yonzhan please trigger checks |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
az postgres flexible-server server-logs list: BUG FIX, command crashes with an AttributeError when listing log filesaz postgres flexible-server server-logs list: Fix 33090, command crashes with an AttributeError when listing log files
|
@calvinhzy and @yonzhan please trigger checks, fix we put in for the title, and we needed this for the April release |
Related command
Description
az postgres flexible-server server-logs listcrashes with an AttributeError when listing log files.Here are the significant differences between LogFile (old) and CapturedLog (new):
Field changes
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 filesThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.