Skip to content

fix(ui): register views synchronously so extensions get their routes - #5725

Merged
SteKoe merged 1 commit into
codecentric:masterfrom
michalformanek:fix/view-registry-add-view-sync
Oct 1, 2026
Merged

SteKoe merged 1 commit into
codecentric:masterfrom
michalformanek:fix/view-registry-add-view-sync

Conversation

@michalformanek

Copy link
Copy Markdown
Contributor

Fixes #5724

Since #5542, ViewRegistry._addView is async, but useViewRegistry().addView (exposed as SBA.viewRegistry) still reads addView(...)[0] as a view. Once the router exists, view.path is undefined and the route registration throws Cannot read properties of undefined (reading 'startsWith'). UI extensions always load after the router is created, so every extension view is affected, including spring-boot-admin-sample-custom-ui.

_addView never awaits anything, so this makes it synchronous again. isEnabled still accepts boolean | Promise<boolean>, so the async enablement from #5542 (MCP view) is unchanged.

Tests: composables/ViewRegistry.spec.ts registers a top-level view and a child view through useViewRegistry() after createRouter(). Both tests failed with the reported TypeError before the change and pass after it. npm run test (554 tests), npm run lint (only the 3 existing warnings), npm run format and npm run build are green.

Verified manually with spring-boot-admin-sample-servlet + spring-boot-admin-sample-custom-ui on 4.1.3 with this patch: "My Extensions" and the instance "Custom" view are back and the console is clean.

Screenshots and recordings: see #5724.

Since codecentric#5542, `ViewRegistry._addView` is `async`, so `addView` returns
promises. `useViewRegistry().addView` (exposed as `SBA.viewRegistry`)
still reads `addView(...)[0]` as a view, so once the router exists
`view.path` is undefined and `ensureAbsolutePath` throws
"Cannot read properties of undefined (reading 'startsWith')".

UI extensions are loaded as <script> tags after the router is created,
so every extension view is affected: it lands in the registry but gets
no route (e.g. "My Extensions" of spring-boot-admin-sample-custom-ui).

`_addView` never awaits anything; only `isEnabled` needs to support
promises, and it still does.
@SteKoe
SteKoe enabled auto-merge (squash) October 1, 2026 14:06
@SteKoe
SteKoe merged commit cf28d13 into codecentric:master Oct 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: UI extension views get no route in 4.1.3 — TypeError: Cannot read properties of undefined (reading 'startsWith')

3 participants