microsoft / microsoft/microsoft-partner-center-github-action

Fix: Dynamically extract resourceType to prevent 400 Bad Request error

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Dynamically extract the resourceType from the existing $configuration variable (which contains the current package configuration)
  2. Use jq to preserve the original resourceType and id fields while updating only the version and packageReferences
Changes Made
  • Replaced the hardcoded JSON template with a dynamic jq transformation
  • The resourceType and id are now preserved from the existing configuration
  • Only version and packageReferences are 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.