Skip to content

Unblock bc login due to pp failures - #10335

Open
rupeshdan wants to merge 1 commit into
mainfrom
bugs/620236
Open

Unblock bc login due to pp failures#10335
rupeshdan wants to merge 1 commit into
mainfrom
bugs/620236

Conversation

@rupeshdan

@rupeshdan rupeshdan commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes AB#620236

What & why

Prevents Business Central sign-in from being blocked when the linked Power Platform environment lookup fails.

The change:

  • Handles lookup failures without surfacing them to the caller and logs telemetry for diagnosis.
  • Ignores null GUID and empty environment responses.
  • Returns a clear error when no Power Platform tenant is configured.
  • Adds integration tests for failed, null, valid, and empty-response scenarios.

Tests and the outcome

Added integration coverage confirming that:

  • Linked-environment lookup failures do not surface or return an environment ID.
  • Null GUIDs are not returned.
  • Valid linked environment IDs are returned.
  • Empty environment responses produce an empty environment buffer.

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.

@rupeshdan
rupeshdan requested a review from a team August 18, 2026 06:47
@github-actions github-actions Bot added the Integration GitHub request for Integration area label Aug 18, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 18, 2026
LinkedEnvironmentId := EnvironmentInformation.GetLinkedPowerPlatformEnvironmentId();
if (LinkedEnvironmentId <> '') and (Evaluate(GUIDValue, LinkedEnvironmentId)) then begin
EnvironmentId := LinkedEnvironmentId;
OnBeforeGetLinkedPowerPlatformEnvironmentId(LinkedEnvironmentId, Handled);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Events}$

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

@github-actions

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Privacy}$

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant