microsoft / microsoft/microsoft-partner-center-github-action
Fix: Dynamically extract resourceType to prevent 400 Bad Request error
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 22
- Forks
- 9
- Avg merge
- 18h 29m
- Merged PRs (30d)
- 1
Description
Problem
The current implementation hardcodes "resourceType": "AzureSolutionTemplatePackageConfiguration" in the application_generateUpdatePackageReferenceRequestBody() function. This causes a 400 Bad Request error when the package configuration uses a different resource type (e.g., AzureApplicationPackageConfiguration).
Error Details
When running the workflow, the API returns:
400 Bad Request: The resourceType in the request body doesn't match the actual resource type
Solution
This PR modifies the application_generateUpdatePackageReferenceRequestBody() function to:
- Dynamically extract the
resourceTypefrom the existing$configurationvariable (which contains the current package configuration) - Use
jqto preserve the originalresourceTypeandidfields while updating only theversionandpackageReferences
Changes Made
- Replaced the hardcoded JSON template with a dynamic
jqtransformation - The
resourceTypeandidare now preserved from the existing configuration - Only
versionandpackageReferencesare updated with new values
Before
cat <<EOF
{
"resourceType": "AzureSolutionTemplatePackageConfiguration", # ❌ Hardcoded
"version": "${artifactVersion}",
"packageReferences": [...]
}
EOF
After
echo "$configuration" | jq --arg v "$artifactVersion" --arg pkg "$packageId" '
.version = $v
| .packageReferences = [
{
"type": "AzureApplicationPackage",
"value": $pkg
}
]
'
Benefits
- ✅ Works with any
resourceType(e.g.,AzureSolutionTemplatePackageConfiguration,AzureApplicationPackageConfiguration) - ✅ Preserves all existing configuration fields
- ✅ Prevents 400 errors due to resource type mismatch
- ✅ More maintainable and flexible
Testing
Tested with workflows that use different resource types and confirmed the 400 error is resolved.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the application_generateUpdatePackageReferenceRequestBody() function in the action's shell implementation and inspect how $configuration is built. Run a workflow using a non-default resourceType, then verify the generated request preserves resourceType and id while updating version and packageReferences without a 400 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, shell
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100