microsoft / coe-starter-kit

Other
748 stars 220 forks source link

[ALM Accelerator - BUG]: Cannot read properties of null (reading id) #4077

Closed kaat03 closed 1 year ago

kaat03 commented 1 year ago

Describe the issue

After merging the newest pull request (https://github.com/microsoft/coe-alm-accelerator-templates/pull/227) we experienced the same "Cannot read properties of null (reading id)" error as in issue (https://github.com/microsoft/coe-starter-kit/issues/3515) in the step "Update deployment settings" in export-solution-to-git pipeline.

Expected Behavior

The pipeline should run without issues.

What component are you experiencing the issue with?

ALM Accelerator Pipelines

What solution version are you using?

1.0.20221004.2

Steps To Reproduce

  1. We imported the newest October release and set up the app.
  2. Encountered an issue with legacy URL.
  3. Merged https://github.com/microsoft/coe-alm-accelerator-templates/pull/227 with main.
  4. Issue with legacy URL was solved but the "Cannot read properties of null (reading id) occurred."

Anything else?

No response

mikefactorial commented 1 year ago

@kaat-gplabs could you supply the logs from where this failure occurred in the pipeline to assist with tracking it down?

kaat03 commented 1 year ago

Here's the log from the failing pipeline step.

Starting: Update Deployment Settings
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.210.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\7cd13c0e-c41c-455f-a894-37a000b2427e.ps1'"
{
    "value":  [
                  {
                      "BuildName":  ,
                      "BuildTemplate":  null,
                      "DeploymentEnvironmentName":  "Test",
                      "DeploymentEnvironmentUrl":  null,
                      "EnvironmentUrl":  ,
                      "ServiceConnectionName":  null,
                      "StepType":  809060001,
                      "UserSettings":  [

                                       ]
                  },
                  {
                      "BuildName":  ,
                      "BuildTemplate":  null,
                      "DeploymentEnvironmentName":  ,
                      "DeploymentEnvironmentUrl":  null,
                      "EnvironmentUrl":  ,
                      "ServiceConnectionName":  null,
                      "StepType":  809060001,
                      "UserSettings":  [

                                       ]
                  }
              ],
    "Count":  2
}
Update Deployment Settings

    Directory: 

Mode                 LastWriteTime         Length Name                                                                 
----                 -------------         ------ ----                                                                 
d-----         11/4/2022  12:27 PM                config                                                               
Retrieved  2  deployment environments

Retrieved  0  branch

Retrieved  0  builds
Retrieved  2  deployment configurations
environments:  ,environments=
info: Branch start
info: Setup branch
info: Using supplied access token
info: Pipeline Project: 
info: Getting Project
info: Getting Pipeline Project
info: Found project 
info: Found pipeline project undefined 
info: An error occurred while creating the branch: TypeError: Cannot read properties of null (reading 'id')
error: Cannot read properties of null (reading 'id')
{"level":"info","message":"Branch start","timestamp":"2022-11-04 12:27:14 PM +0000"}
{"level":"info","message":"Setup branch","timestamp":"2022-11-04 12:27:14 PM +0000"}
{"level":"info","message":"Using supplied access token","timestamp":"2022-11-04 12:27:14 PM +0000"}
{"level":"info","message":"Pipeline Project: ","timestamp":"2022-11-04 12:27:14 PM +0000"}
{"level":"info","message":"Getting Project","timestamp":"2022-11-04 12:27:15 PM +0000"}
{"level":"info","message":"Getting Pipeline Project","timestamp":"2022-11-04 12:27:15 PM +0000"}
{"level":"info","message":"Found project  ","timestamp":"2022-11-04 12:27:15 PM +0000"}
Importing PowerShell Module: D:\a\1\_coe\ALM_ACC\da\2.8.14\Microsoft.Xrm.Data.PowerShell - 2.8.14

Retrieved  0  builds
Creating 

    Directory: 

Mode                 LastWriteTime         Length Name                                                                 
----                 -------------         ------ ----                                                                 
d-----         11/4/2022  12:27 PM                Test                                                                 
Creating deployment settings
Creating custom deployment settings

Retrieved  0  builds
Creating  -Name  -ItemType directory
d-----         11/4/2022  12:27 PM                                                                   
Creating deployment settings
Creating custom deployment settings

##[error]PowerShell exited with code '1'.
Finishing: Update Deployment Settings
mikefactorial commented 1 year ago

Looks like there might be a bug. However, as a workaround try the following.

  1. Edit the export pipeline from Azure DevOps
  2. Add the following variables
    • Name: PipelineProject Value: The name of the project that contains your pipeline templates (this is usually the same project where the export pipeline is running)
    • Name: PipelineRepository Value: The name of the repository that contains your pipeline templates in the project above.
  3. Save the pipeline and rerun the failed export.
kaat03 commented 1 year ago

Thanks for the reply! Unfortunately, the same error still occurs after the variables have been added.

kaat03 commented 1 year ago

We managed to solve this issue, looks like it was spaces in the project name that were causing this to happen.

mikefactorial commented 1 year ago

@kaat-gplabs thanks for reporting back. Will look into what's going on here with spaces in the project name

J3ffr0y3d commented 1 year ago

hi, we are also having the same issue, we get the error when we commit to older repos, newly created repos dont seem to have the issue, all in the same project (Power Platform).

we have tried what you suggested but still the same error. we are on the november release.

Update Deployment Settings
Retrieved  3  deployment environments
https://dev.azure.com/Source/Power Platform/_apis/git/repositories/fgfg.hq.jjfjhfghfghfghfgh/refs?filter=heads/fgfghqjjfjhfghfghfghfgh&api-version=6.0
Retrieved  0  branch
https://dev.azure.com/Source/Power Platform/_apis/build/definitions?name=deploy-*-fgfghqjjfjhfghfghfghfgh&includeAllProperties=true&api-version=6.0
Retrieved  3  builds
Retrieved  3  deployment configurations
environments:  validation=[https://123456789.crm4.dynamics.com/,validation-buildname=deploy-validation-fgfghqjjfjhfghfghfghfgh,test=https://123456789.crm4.dynamics.com/,test-buildname=deploy-test-fgfghqjjfjhfghfghfghfgh,prod=https://123456789.crm4.dynamics.com/,prod-buildname=deploy-prod-fgfghqjjfjhfghfghfghfgh,environments=Validation|Test|Prod](https://123456789.crm4.dynamics.com/,validation-buildname=deploy-validation-fgfghqjjfjhfghfghfghfgh,test=https://123456789.crm4.dynamics.com/,test-buildname=deploy-test-fgfghqjjfjhfghfghfghfgh,prod=https://123456789.crm4.dynamics.com/,prod-buildname=deploy-prod-fgfghqjjfjhfghfghfghfgh,environments=Validation%7CTest%7CProd)
info: Branch start
info: Setup branch
info: Using supplied access token
info: Pipeline Project: Power%20Platform
info: Getting Project
info: Getting Pipeline Project
info: Found project Power Platform Power Platform
info: Found pipeline project undefined Power%20Platform
info: An error occurred while creating the branch: TypeError: Cannot read properties of null (reading 'id')
error: Cannot read properties of null (reading 'id')
{"level":"info","message":"Branch start","timestamp":"2022-11-15 03:52:14 PM +0000"}
{"level":"info","message":"Setup branch","timestamp":"2022-11-15 03:52:14 PM +0000"}
{"level":"info","message":"Using supplied access token","timestamp":"2022-11-15 03:52:14 PM +0000"}
{"level":"info","message":"Pipeline Project: Power%20Platform","timestamp":"2022-11-15 03:52:14 PM +0000"}
{"level":"info","message":"Getting Project","timestamp":"2022-11-15 03:52:14 PM +0000"}
{"level":"info","message":"Getting Pipeline Project","timestamp":"2022-11-15 03:52:14 PM +0000"}
{"level":"info","message":"Found project Power Platform Power Platform","timestamp":"2022-11-15 03:52:14 PM +0000"}
Importing PowerShell Module: D:\a\1\_coe\ALM_ACC\da\2.8.14\Microsoft.Xrm.Data.PowerShell - 2.8.14
https://dev.azure.com/Source/Power Platform/_apis/build/definitions?name=deploy-validation-fgfghqjjfjhfghfghfghfgh&includeAllProperties=true&api-version=6.0
Retrieved  1  builds
Inside Create-Update-ServiceConnection-Parameters
newBuildDefinitionVariables - 
0
gerald560 commented 1 year ago

same issue here as well

info: Branch start info: Setup branch info: Using supplied access token info: Pipeline Project: Power%20Automate%20Governance info: Getting Project info: Getting Pipeline Project info: Found project Power Automate Governance Power Automate Governance info: Found pipeline project undefined Power%20Automate%20Governance info: An error occurred while creating the branch: TypeError: Cannot read properties of null (reading 'id') error: Cannot read properties of null (reading 'id')

mikefactorial commented 1 year ago

Thanks all for the feedback here. Based on the feedback and some internal testing does appear to be related to projects with spaces in the name and encoding of the name a fix is in the works.

mikefactorial commented 1 year ago

For those of you who this is blocking see the PR above for the fix. This has been validated internally, but if there's any feedback. Feel free to let us know. It's a fairly straightforward change in 1 of the YAML templates.

J3ffr0y3d commented 1 year ago

@mikefactorial thanks for that, all working now, i am curious though as to why it only affected our older repos and not the newly created ones.

mikefactorial commented 1 year ago

@J3ffr0y3d can't explain why that would be. The root cause of the issue was related to spaces in Project Names and how it was encoded in the pipeline variable we were using.

CoEStarterKitBot commented 1 year ago

@kaat-gplabs This has been fixed in the latest release. Please install the latest version of the toolkit following the instructions for installing updates. Note that if you do not remove the unmanaged layers as described there you will not receive updates from us.

mindlessroman commented 1 year ago

FWIW - @mikefactorial I believe the bot is linking to an old link > https://learn.microsoft.com/en-us/power-platform/guidance/coe/after-setup for updating?