microsoft / powerplatform-actions

Power Platform GitHub Actions automate common build and deployment tasks related to Power Platform. This includes synchronization of solution metadata (a.k.a. solutions) between development environments and source control, generating build artifacts, deploying to downstream environments, provisioning/de-provisioning of environments, and the ability to perform static analysis checks against your solution using the PowerApps checker service.
MIT License
221 stars 68 forks source link

[solution-import] add more descriptive error message when a solution environment variable is missing #249

Open henricson opened 2 years ago

henricson commented 2 years ago

Hi,

I had an issue where my unmanaged solution import failed with the very undescriptive message "Error: The given key was not present in the dictionary.".

After a lot of testing, I think I have isolated the error to be related to not having defined a deployment setting file, containing the required environment variable for my solution.

Here is my step-config; adding the last two lines resolved the error:

 - name: Import solution as unmanaged to build env
        uses: microsoft/powerplatform-actions/import-solution@v0
        with:
          environment-url: ${{inputs.BUILD_ENVIRONMENT_URL}}
          app-id: ${{inputs.CLIENT_ID}}
          client-secret: ${{ secrets.envSecret }}
          tenant-id: ${{inputs.TENANT_ID}}
          solution-file: ${{ inputs.solution_outbound_folder}}/${{ inputs.solution_name }}.zip
          force-overwrite: true
          publish-changes: true
          run-asynchronously: true
          use-deployment-settings-file: true
          deployment-settings-file: "env.json"

It took me some time to isolate the cause of this error, and I think it would be great to include a more descriptive error message.

The origin of the error message seems to be the target environment itself, so I guess an immediate fix would to be to add some client-side validations on the solution-import action, checking the contents environmentvariabledefinition.xml.

henricson commented 2 years ago

Some additional information: it seems that the issue only occurs when importing an unmanaged solution. In my latter steps, while doing an import of a managed version of this solution, I was able to import without providing environment variables. These were, as expected, requested in the web-ui on make.powerapps.com after the successful first import.