microsoft / microsoft/AL-Go

[Bug]: Incremental PR build reuses an older baseline app than the previous release

Open
#2,373 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
506
Forks
203
Avg merge
4d 22h
Merged PRs (30d)
6

Description

AL-Go version

9.2

Describe the issue

An incremental PR build using modifiedApps can reuse an app from the baseline CI/CD run that is older than the same app in the latest release.

This can happen when the latest release was created from a release branch while the last successful CI/CD run on main still contains an older version of the app.

Example:

Source Branch App version
Last successful CI/CD main 1.0.100.0
Release CI/CD release branch 1.0.101.0
Latest release release branch 1.0.101.0

When a PR against main does not modify this app, the incremental build restores version 1.0.100.0 from the baseline CI/CD run and treats it as a prebuilt app.

At the same time, version 1.0.101.0 from the latest release is used as previousApps.

The effective sequence in Run-AlPipeline is:

  1. 1.0.101.0 from previousApps is published, synchronized and installed.
  2. 1.0.100.0 from the baseline CI/CD run is published afterwards as a prebuilt app.
  3. Synchronizing 1.0.100.0 fails because 1.0.101.0 has already been synchronized.

The resulting error is:

Cannot synchronize extension App because a newer version has already been synchronized with app ID ...

So the incremental build effectively combines:

Previous release: 1.0.101.0
Prebuilt app from baseline CI/CD: 1.0.100.0

The problem is that the older baseline artifact is reused as a prebuilt app even though the selected previous release already contains a newer version of the same App ID.

Expected behavior

The incremental build should not attempt to publish or synchronize an app version that is older than the version of the same App ID already selected as previousApps.

The build should not end up with:

previousApps = 1.0.101.0
prebuilt app = 1.0.100.0

followed by an attempt to synchronize 1.0.100.0 after 1.0.101.0 has already been synchronized.

Steps to reproduce
  1. Run CI/CD on main so the Apps artifact contains an app with version 1.0.100.0.
  2. Create a release branch.
  3. Run CI/CD on the release branch so the same app has version 1.0.101.0.
  4. Create a release from that release branch containing version 1.0.101.0.
  5. Do not run another CI/CD on main.
  6. Create a PR targeting main which does not modify this app.
  7. Run the PR build with incremental builds using modifiedApps.

The PR build retrieves the unchanged app from the baseline workflow run on main:

Get unmodified apps from baseline workflow run

Branch for workflow run ... is main
Found artifact ...-main-Apps-1.0.100.0
Downloading artifact ...-main-Apps-1.0.100.0
Copy ..._App_1.0.100.0.app to build folders

It is later detected as a prebuilt app:

Using prebuilt app ...\.buildartifacts\Apps\...\App_1.0.100.0.app

The build then installs the newer previous release first and afterwards tries to publish the older prebuilt app.

Additional context (logs, screenshots, etc.)

The following sanitized excerpts are from the same failing PR build and show the sequence that leads to the failure.

1. The unchanged app is restored from the main baseline
Get unmodified apps from baseline workflow run

Branch for workflow run ... is main
Found artifact ...-main-Apps-1.0.100.0
Downloading artifact ...-main-Apps-1.0.100.0

Copy ..._App_1.0.100.0.app to build folders

Run-AlPipeline later recognizes the restored app as a prebuilt app:

Using prebuilt app ...\.buildartifacts\Apps\...\App_1.0.100.0.app
2. The newer version from the latest release is installed first

The selected previousApps contain version 1.0.101.0:

Installing previous apps

Publishing ..._App_1.0.101.0.app
Synchronizing App on tenant default
Installing App on tenant default
App ..._App_1.0.101.0.app successfully published

At this point 1.0.101.0 has been successfully synchronized and installed.

3. The older prebuilt app is published afterwards

The pipeline then enters Publishing apps and tries to publish the older baseline version:

Publishing apps

Publishing ..._App_1.0.100.0.app
Synchronizing App on tenant default

Cannot synchronize extension App because a newer version has already been synchronized with app ID ...

The relevant sequence is therefore:

latest release / previousApps
1.0.101.0
    |
    v
synchronized + installed

baseline CI/CD / prebuilt app
1.0.100.0
    |
    v
published afterwards
    |
    v
synchronization fails
Current workaround

Deleting the outdated Apps artifact from the baseline CI/CD run on main prevents AL-Go from restoring the older app as a prebuilt app. The PR build then succeeds.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Run-AlPipeline and trace the incremental-build flow for modifiedApps, including how previousApps and baseline Apps artifacts become prebuilt apps. Compare app versions by App ID before publishing or synchronizing. Done means an older baseline app is not processed when a newer version is already selected from the latest release, and the described PR build succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.