Describe the issue
Invoke-Miapp throws immediately when the -Country parameter is used. The regular expression that extracts the country code from a layer path is missing a closing parenthesis, so .NET rejects the pattern before any file is integrated:
IntegrateBranchedObjects: Invalid pattern 'src/Layers/(?<Country>.+?(?=/)' at offset 30. Not enough )'s.
Root cause — build/scripts/Miapp/MicroAppIntegrate.psm1, line 180:
$Matched = $branch -match 'src/Layers/(?<Country>.+?(?=/)'
The named group (?<Country> is opened but never closed. The lookahead (?=/) closes its own parenthesis, leaving the group unterminated.
The same function in the internal NAV repository has the correct pattern (Eng/Normal/Lib/GitMiapp/MicroAppIntegrate.psm1):
$Matched = $branch -match 'App/Layers/(?<Country>.+?(?=/))'
so the parenthesis was lost when the pattern was adapted from App/Layers/ to src/Layers/ for this repository. The BCApps copy has been wrong since it was introduced in 748fdaa ("Sync from BCAppsPrivate + NAV (efe2d9954d)", #8848), and main still has it.
Without -Country the tool works, because the faulty pattern sits inside if($Params.Country) and is only evaluated when the parameter is set. That is why it has gone unnoticed — targeting a single layer is exactly what you do when trying the tool out or verifying propagation for one country.
Expected behavior
The country code is extracted from the layer path and compared with the -Country argument, so only files belonging to that layer are integrated.
Steps to reproduce
- Make a change to any file under
src/Layers/W1/ that has a counterpart in a country layer.
- Run
Invoke-Miapp -Country DK (any country code reproduces it).
- The command throws
Invalid pattern ... Not enough )'s. before integrating anything.
Additional context
Suggested fix — add the missing parenthesis:
- $Matched = $branch -match 'src/Layers/(?<Country>.+?(?=/)'
+ $Matched = $branch -match 'src/Layers/(?<Country>.+?(?=/))'
Verified locally. Before the fix the pattern cannot be compiled at all; after it, the country code is captured as expected, including multi-character layer names, since .+? is lazy up to the next /:
'src/Layers/DK/BaseApp/Sales/Foo.al' -match 'src/Layers/(?<Country>.+?(?=/))' # True, Country = 'DK'
'src/Layers/W1/BaseApp/Foo.al' -match 'src/Layers/(?<Country>.+?(?=/))' # True, Country = 'W1'
'src/Layers/APAC/BaseApp/Foo.al' -match 'src/Layers/(?<Country>.+?(?=/))' # True, Country = 'APAC'
Impact: -Country is unusable, which forces a full propagation to all layers even when only one is of interest. Low risk to fix — one character, in a code path that currently always throws.
Describe the issue
Invoke-Miappthrows immediately when the-Countryparameter is used. The regular expression that extracts the country code from a layer path is missing a closing parenthesis, so .NET rejects the pattern before any file is integrated:Root cause —
build/scripts/Miapp/MicroAppIntegrate.psm1, line 180:The named group
(?<Country>is opened but never closed. The lookahead(?=/)closes its own parenthesis, leaving the group unterminated.The same function in the internal NAV repository has the correct pattern (
Eng/Normal/Lib/GitMiapp/MicroAppIntegrate.psm1):so the parenthesis was lost when the pattern was adapted from
App/Layers/tosrc/Layers/for this repository. The BCApps copy has been wrong since it was introduced in 748fdaa ("Sync from BCAppsPrivate + NAV (efe2d9954d)", #8848), andmainstill has it.Without
-Countrythe tool works, because the faulty pattern sits insideif($Params.Country)and is only evaluated when the parameter is set. That is why it has gone unnoticed — targeting a single layer is exactly what you do when trying the tool out or verifying propagation for one country.Expected behavior
The country code is extracted from the layer path and compared with the
-Countryargument, so only files belonging to that layer are integrated.Steps to reproduce
src/Layers/W1/that has a counterpart in a country layer.Invoke-Miapp -Country DK(any country code reproduces it).Invalid pattern ... Not enough )'s.before integrating anything.Additional context
Suggested fix — add the missing parenthesis:
Verified locally. Before the fix the pattern cannot be compiled at all; after it, the country code is captured as expected, including multi-character layer names, since
.+?is lazy up to the next/:Impact:
-Countryis unusable, which forces a full propagation to all layers even when only one is of interest. Low risk to fix — one character, in a code path that currently always throws.