Skip to content

Conversation

@tundwed
Copy link
Member

@tundwed tundwed commented Nov 26, 2025


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

Related command

{edge-action}

General Guidelines

  • [ x] Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • [x ] Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • [ x] My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Danny Tundwe (from Dev Box) added 3 commits November 24, 2025 17:00
- Added Content-Type: application/json header to POST request
- Expanded Accept header to include text/plain and */* for better compatibility
- Resolves 'Unsupported Media Type' error when calling get-version-code
- Added test case for get-version-code command

The fix ensures proper HTTP headers are sent for the getVersionCode operation,
which is a POST request with no body. Some Azure services require both
Content-Type and Accept headers to be present even for empty-body requests.
…ension

- Add Content-Type and Accept headers to get-version-code and swap-default POST operations
- Add empty JSON body '{}' required by the API for POST operations without payload
- Add --output-directory parameter to get-version-code to decode and save zip files
- Comment out execution-filter CRUD test (service returns HTTP URLs in LRO headers, needs service-side fix)
- Re-record all passing tests

The root cause was that AAZ-generated code for POST operations without a request body
was not sending Content-Type header or empty body, causing the API to reject with 415.
Copilot AI review requested due to automatic review settings November 26, 2025 01:53
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Nov 26, 2025

⚠️Azure CLI Extensions Breaking Change Test
⚠️edge-action
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd edge-action version get-version-code cmd edge-action version get-version-code added parameter output_directory

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 26, 2025

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

@github-actions
Copy link

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>

@github-actions
Copy link

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

Copilot finished reviewing on behalf of tundwed November 26, 2025 01:54
@github-actions
Copy link

@necusjz
Copy link
Member

necusjz commented Nov 26, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
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 fixes bugs in the edge-action extension related to "415 Unsupported Media Type" errors occurring in POST operations for get-version-code and swap-default commands.

Key changes:

  • Added required HTTP headers (Content-Type and Accept) and empty JSON body to POST requests
  • Enhanced get-version-code command with an optional --output-directory parameter to decode and save version code as a zip file
  • Updated extension version from 1.0.0b1 to 1.0.0b2

Reviewed changes

Copilot reviewed 8 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/edge-action/setup.py Bumped version to 1.0.0b2
src/edge-action/HISTORY.rst Added release notes for 1.0.0b2 documenting the bug fixes and new feature
src/edge-action/azext_edge_action/aaz/latest/edge_action/version/_get_version_code.py Fixed HTTP headers/body for API request and added output directory functionality for decoding/saving zip files
src/edge-action/azext_edge_action/aaz/latest/edge_action/version/_swap_default.py Fixed HTTP headers/body for API request
src/edge-action/azext_edge_action/tests/latest/test_edge_action.py Added test for get-version-code command
src/edge-action/azext_edge_action/tests/latest/recordings/*.yaml Updated test recordings with new test data and timestamps

Comment on lines +112 to +116
try:
decoded_content = base64.b64decode(content)
except Exception as e:
from azure.cli.core.azclierror import ValidationError
raise ValidationError(f"Failed to decode base64 content: {str(e)}")
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

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

Using bare except Exception is too broad. Consider catching specific exception types (e.g., base64.binascii.Error for base64 decoding errors) or at minimum re-raising unexpected exceptions after logging them. This will make debugging easier and prevent masking unexpected errors.

Copilot uses AI. Check for mistakes.
f.write(decoded_content)
logger.warning(f"Version code saved to: {output_file}")
return {"message": f"Version code saved to: {output_file}", "file": output_file}
except Exception as e:
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

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

Using bare except Exception is too broad here as well. Consider catching specific file I/O exceptions (e.g., IOError, OSError, PermissionError) to provide more precise error handling.

Suggested change
except Exception as e:
except (OSError, PermissionError) as e:

Copilot uses AI. Check for mistakes.
@necusjz necusjz merged commit fe10f0e into Azure:main Nov 26, 2025
31 of 32 checks passed
@azclibot
Copy link
Collaborator

[Release] Update index.json for extension [ edge-action-1.0.0b2 ] : https://dev.azure.com/msazure/One/_build/results?buildId=144845648&view=results

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.

4 participants