Skip to content

Avoid error dialog during login redirect - #3519

Open
Piyushkumar481 wants to merge 4 commits into
openremote:mainfrom
Piyushkumar481:fix/manager-login-redirect
Open

Piyushkumar481 wants to merge 4 commits into
openremote:mainfrom
Piyushkumar481:fix/manager-login-redirect

Conversation

@Piyushkumar481

Copy link
Copy Markdown

What does this PR fix?

When an unauthenticated user opens the Manager, Keycloak's check-sso flow can trigger a login redirect. During this expected redirect, the Manager could briefly display an unwanted error dialog.

Changes

  • Show the Manager error dialog only when manager.isError is true.
  • Avoid displaying an error dialog when initialization returns false because of the expected login redirect.
  • Add a regression test for the unauthenticated login redirect flow.

Testing

  • Manager build completed successfully.
  • OpenRemote component build completed successfully.
  • Manager login redirect Playwright test executed successfully.
  • TypeScript test compilation completed successfully.

@CLAassistant

CLAassistant commented Oct 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@wborn
wborn requested a review from MartinaeyNL October 30, 2026 08:30
@wborn wborn changed the title fix(manager): avoid error dialog during login redirect Avoid error dialog during login redirect Oct 30, 2026
@wborn wborn added the Bug Error or issue in the system label Oct 30, 2026
…ILED_TO_LOAD as fallback during manager initialization.

@MartinaeyNL MartinaeyNL left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @Piyushkumar481 !
Thanks for opening a pull request!

I've pushed a few minor changes to your branch, focusing on edge cases when manager initialization fails.
Now, in case of the login redirect, it hides the errorOccurred error (your fix), but still shows a log.debug() message.
When something else fails during initialization, without any error message being set, it falls back to MANAGER_FAILED_TO_LOAD.
It's a bit more robuust like this, in my opinion.

I'm happy with the changes right now, I will double check with @Ekhorn on the test file. 👍

I see I accidentally used manager.isError instead of this.isError, will commit it soon

@sonarqubecloud

Copy link
Copy Markdown

@Ekhorn Ekhorn left a comment

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.

This is an additional AI-assisted review.

The or-app and Manager changes look right: manager.init() now only returns false without an error for the auto-login redirect, which no longer opens the empty error dialog, and every other failure path still ends with an error set, so its dialog keeps a message.

The new regression test cannot fail in its current form, so it does not guard the fix yet; details inline.


await expect(page.getByRole("heading", { name: "Sign in to your account" })).toBeVisible();

const appearances = await page.evaluate(() => (window as any).__errorDialogAppearances);

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.

page.addInitScript runs again in every new document, so this page.evaluate reads window.__errorDialogAppearances from the Keycloak sign-in page, where the init script has just created a fresh, empty array. Whatever the observer recorded on the manager page is discarded with that document, so the assertion passes with and without the or-app change: the dialog used to open on the manager page that loads after the check-sso round trip, just before it redirects to the sign-in page.

Collecting the appearances in the test through page.exposeFunction, which survives navigations, keeps the record across the redirect:

const errorDialogs: string[] = [];
await page.exposeFunction("reportErrorDialog", (url: string) => errorDialogs.push(url));

The observer then calls (window as any).reportErrorDialog(location.href) instead of appearances.push(...), and the assertion becomes:

// The manager page loaded after the check-sso round trip used to show an empty "An error has occurred" dialog
// while redirecting to the sign-in page
expect(errorDialogs).toEqual([]);

ui/AGENTS.md asks for a regression test that fails without the fix and a comment on the assertion recording what used to go wrong, so it is worth confirming the test fails with the or-app/src/index.ts change reverted.


test.use({ storageState: { cookies: [], origins: [] } });

test("does not show an error dialog during the unauthenticated login redirect", async ({ page, manager }) => {

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.

ui/AGENTS.md asks for test names starting with "should ..." and @given/@when/@then scenario comments above app tests, like the other manager tests:

Suggested change
test("does not show an error dialog during the unauthenticated login redirect", async ({ page, manager }) => {
/**
* @given An unauthenticated visitor
* @when The start page of the "master" realm is opened
* @then The manager redirects to the Keycloak sign-in page without showing an error dialog
*/
test("should not show an error dialog during the unauthenticated login redirect", async ({ page, manager }) => {

This branch has not been deployed

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

Labels

Bug Error or issue in the system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

errorOccured pop-up is sometimes visible when visiting manager login page

5 participants