[IT] Precheck subcontracting migration locations - #11001
[IT] Precheck subcontracting migration locations#11001Chethan Thopaiah (ChethanT) wants to merge 6 commits into
Conversation
Block migration when legacy subcontracting locations use unsupported warehouse settings and report every affected location. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The migration precheck marked CheckSubcontractingLocations with ErrorBehavior::Collect but never handled the collection, so it fell back to the platform's concatenated error dialog (a BCQuality error-handling anti-pattern). After collecting every unsupported subcontracting location, inspect HasCollectedErrors, retrieve and clear the list with GetCollectedErrors(true), and raise a single deliberate blocking error. Update the precheck test to assert the aggregated blocking error via asserterror/GetLastErrorText. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Good Sense Reviewer - Round 1Recommendation: Request ChangesWhat this PR doesThis change adds a precheck before the IT subcontracting migration copies legacy subcontracting location codes into the new fields. It gathers the vendor and purchase-header locations, reports each unsupported warehouse setting, and adds tests for multiple locations and for stopping before vendor data is copied. The static validation path is mostly correct: the check runs before RunMigration(), uses the same vendor and purchase-header filters as the migration, and reports collected errors instead of stopping at the first bad location. The remaining problem is that the check runs before the migration locks the source data, so the data that is checked is not guaranteed to be the data that is migrated. Problem-solution fitFit: Partial The bug says migration must stop before unsupported subcontracting locations are copied into the new setup. The change covers the normal single-session path, but it still allows a change between the precheck and the locked migration section. SuggestionsS1 (🔴 High): Run the location check under the migration locks Risk assessment and necessityRisk: The touched path is the one-way IT subcontracting migration for Vendor and Purchase Header location fields. If the precheck misses changed data, migrated records can still contain locations that the new subcontracting app rejects, which leaves setup and open documents hard to repair. There is no event publisher dependency to verify for this change. Necessity: The change is needed because copying these fields without validation can leave migrated data in an unsupported state. The scope is right for a bug fix, and the added tests cover the main failure path, but the locking gap should be closed before merge.
|
Good Sense Reviewer - Round 2Recommendation: Request ChangesWhat this PR doesThe new commit changes the precheck so collected location errors are turned into one deliberate blocking error. That improves the error path for tests and for callers, but it does not change when the precheck runs. The main correctness gap is still open. The precheck still runs before the migration locks Vendor and Purchase Header, and Location is not locked or reread under those locks. The checked data is therefore not guaranteed to be the same data that migration copies. Status of previous suggestions
New observations (commits since round 1)None - the new commit only changes collected-error handling. Risk assessment and necessityRisk: The touched path is the one-way IT subcontracting migration for Vendor and Purchase Header location fields. If source records or location warehouse settings change after the precheck, migration can still persist unsupported subcontracting locations and leave setup or open documents hard to repair. There is no event publisher dependency to verify for this change. Necessity: The change is needed because copying legacy subcontracting location codes without validation can leave migrated data in an unsupported state. The scope is still right for a bug fix, and the added tests cover the normal failure path, but the locking gap should be closed before merge.
|
Revalidate legacy locations under table locks, report orphaned references safely, and add focused regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the locking race identified by Good Sense Reviewer rounds 1 and 2 (comments #5525621750 and #5530204298) in commit |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Good Sense Reviewer - Round 3Recommendation: AcceptWhat this PR doesThe new commits keep the early location precheck for prompt UX, then rerun the authoritative precheck after table locks are taken and before migration writes data. They also lock Location, report missing legacy location references, aggregate collected errors into one blocking client error, and update tests for the new behavior. This addresses the previous data race. The checked Vendor, Purchase Header, and Location data is now read after the migration locks and immediately before RunMigration(), so the data being validated is the data that is about to be migrated. Status of previous suggestions
New observations (commits since round 2)None - the new commits address the previous locking gap and tighten the error aggregation tests. Risk assessment and necessityRisk: The touched path is the one-way IT subcontracting migration for Vendor and Purchase Header location fields. An incorrect check could still leave invalid subcontracting locations in migrated data, but the authoritative precheck now runs under locks before any migration writes. There is no event publisher dependency to verify for this change. Necessity: The change is needed because copying legacy subcontracting location codes without validation can leave migrated data in a state the new subcontracting setup rejects. The scope remains right for a bug fix, and the tests cover multiple invalid locations, missing locations, and the no-data-moved failure path.
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| LibraryWarehouse: Codeunit "Library - Warehouse"; | ||
| LibraryUtility: Codeunit "Library - Utility"; | ||
| Initialized: Boolean; | ||
| SubcontractingLocationsBlockedErr: Label 'Migration can''t start because one or more subcontracting locations are invalid.'; |
There was a problem hiding this comment.
The new negative tests duplicate the production error texts in test-local Labels and then assert those full formatted messages. The asserterror guidance prefers a shared Label/assert helper or at least a stable invariant fragment, because duplicated full messages drift easily and can make the test fail on wording churn instead of behavior.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.38.6
What
Why
The migration copied legacy location codes directly into the new subcontracting fields, bypassing the target validation and leaving migrated records in an unsupported state.
Tests
Review
ADO bug: 648577
AB#648577