Skip to content

[Contribution Process Bug]: Invoke-Miapp -Country fails on an unbalanced parenthesis in the country regex #10419

Description

@MSlenejennum

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

  1. Make a change to any file under src/Layers/W1/ that has a counterpart in a country layer.
  2. Run Invoke-Miapp -Country DK (any country code reproduces it).
  3. 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.

Metadata

Metadata

Assignees

Labels

Contribution-BugSomething isn't working in the contribution processSCMGitHub request for SCM area

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions