Unblock bc login due to pp failures - #10335
Conversation
| LinkedEnvironmentId := EnvironmentInformation.GetLinkedPowerPlatformEnvironmentId(); | ||
| if (LinkedEnvironmentId <> '') and (Evaluate(GUIDValue, LinkedEnvironmentId)) then begin | ||
| EnvironmentId := LinkedEnvironmentId; | ||
| OnBeforeGetLinkedPowerPlatformEnvironmentId(LinkedEnvironmentId, Handled); |
There was a problem hiding this comment.
The new OnBeforeGetLinkedPowerPlatformEnvironmentId hook passes a var Handled flag without resetting it to false immediately before the raise. Add Handled := false; on the line before OnBeforeGetLinkedPowerPlatformEnvironmentId(...) so the override path stays deterministic and self-documenting, consistent with the existing handled-event pattern elsewhere in this codeunit.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
// if not, use the linked environment if exists
Handled := false;
OnBeforeGetLinkedPowerPlatformEnvironmentId(LinkedEnvironmentId, Handled);
if not Handled then
LinkedEnvironmentId := EnvironmentInformation.GetLinkedPowerPlatformEnvironmentId();Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.33.4
|
GetEnvironments requests an Azure AD access token before it checks whether GetFlowEnvironmentsApi() returned a tenant URL. When the Business Central environment is not linked to a Power Platform tenant, every invocation pays the token-acquisition cost and then errors immediately. Resolve FlowEnvironmentsUrl first and raise PowerPlatformTenantNotConfiguredErr before requesting the access token. Suggested fix (apply manually — could not be anchored as a one-click suggestion): // Gets a list of Flow user environments from the Flow API.
FlowEnvironmentsUrl := GetFlowEnvironmentsApi();
if FlowEnvironmentsUrl = '' then
Error(PowerPlatformTenantNotConfiguredErr);
AccessToken := AzureAdMgt.GetAccessTokenAsSecretText(FlowARMResourceUrlTxt, FlowResourceNameTxt, false);
if AccessToken.IsEmpty() then
Session.LogMessage('0000MJX', EmptyAccessTokenTelemetryMsg, Verbosity::Error, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', PowerAutomatePickerTelemetryCategoryLbl);Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.33.4 |
|
|
||
| LastErrorCode := GetLastErrorCode(); | ||
| EnvironmentId := ''; | ||
| Session.LogMessage('0000Q7B', StrSubstNo(LinkedEnvironmentLookupFailedMsg, Scenario, LastErrorCode), Verbosity::Error, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', PowerAutomatePickerTelemetryCategoryLbl); |
There was a problem hiding this comment.
The new Session.LogMessage call builds its telemetry message with StrSubstNo(LinkedEnvironmentLookupFailedMsg, Scenario, LastErrorCode). Privacy/telemetry guidance expects the message text to stay static, non-personal, and bounded, with structured context moved into custom dimensions instead of being baked into the free-text message. Embedding the caller-supplied Scenario and the raw GetLastErrorCode() value directly in the message makes the payload unbounded and harder to prove non-personal, so DataClassification::SystemMetadata may not match what actually ships. Keep the message constant and move Scenario/error-code into custom dimensions with a documented, bounded schema.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.33.4
| end; | ||
|
|
||
| [Test] | ||
| procedure EmptyEnvironmentResponseIsNotParsed() |
There was a problem hiding this comment.
The new test suite covers linked-environment lookup failures and an empty HTTP response, but it does not exercise the new GetEnvironments() branch where GetFlowEnvironmentsApi() returns an empty string and raises PowerPlatformTenantNotConfiguredErr. Add a negative test that forces the tenant URL lookup to be empty and asserts that specific error so this new failure mode cannot regress unnoticed.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.33.4
Fixes AB#620236
What & why
Prevents Business Central sign-in from being blocked when the linked Power Platform environment lookup fails.
The change:
Tests and the outcome
Added integration coverage confirming that:
Risk & compatibility
Low risk. The change preserves successful environment lookup behavior while preventing Power Platform failures from blocking Business Central sign-in. No data upgrade or breaking API changes are introduced.