azure-ad-b2c / vscode-extension

Azure AD B2C VS code extension
MIT License
64 stars 37 forks source link

Policy Build throws error due to missing 'journeys' element #72

Closed DavidHoerster closed 2 years ago

DavidHoerster commented 2 years ago

Extension version: 1.3.2 I have a series of policy files, each of which contains either BuildingBlocks, ClaimsProviders, UserJourneys, or RelyingParty elements. When I use the extensions "Policy Build" command (Ctrl + Shift + 5 shortcut), the policies are not built and I see the following stack trace in the Dev Tools:

  ERR Cannot read property 'journeys' of undefined: TypeError: Cannot read property 'journeys' of undefined
    at Policy.hasPolicyId (c:\Users\<name>\.vscode\extensions\azureadb2ctools.aadb2c-1.3.2\out\OrchestrationStepsRenumber.js:114:29)
    at Policy.process (c:\Users\<name>\.vscode\extensions\azureadb2ctools.aadb2c-1.3.2\out\OrchestrationStepsRenumber.js:146:40)
    at Policy.process (c:\Users\<name>\.vscode\extensions\azureadb2ctools.aadb2c-1.3.2\out\OrchestrationStepsRenumber.js:135:23)
    at Function.RenumberPolicies (c:\Users\<name>\.vscode\extensions\azureadb2ctools.aadb2c-1.3.2\out\OrchestrationStepsRenumber.js:52:20)
    at c:\Users\<name>\.vscode\extensions\azureadb2ctools.aadb2c-1.3.2\out\PolicyBuild.js:61:62
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

It looks like a recent PR ( #69 ) references this.journeys.has(...) in hasPolicyId which is causing this issue.

Should this read this.base.journeys.has(...) instead?

Rolling back to 1.3.1 allows me to build policies again.

yoelhor commented 2 years ago

I have added the base (and changed the name to basePolicy). Not sure if this change fixes the issue. Anyway, the code is reorganized into two different classes. One for single policy renumber and the other one for multiple. The issue that you have reported is related to the multiple and it's done due to the fact that the build operation calls the orchestration steps renumber. Pleas check out the new version, it MAY solve the problem. If not, pleas change the autoRenumber to false (until this issue is fixed).

DavidHoerster commented 2 years ago

Setting autoRenumber does allow for policy building to work with 1.3.3 now. I'll also take a look at the code to see how to get autoRenumber working.

yoelhor commented 2 years ago

Fixed with version 1.3.4