Skip to content

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

Description

@michalformanek

Spring Boot Admin Server information

  • Version: 4.1.3 (still present on master at 9d66716)
  • Spring Boot version: 4.1.1
  • Configured Security: none needed to reproduce (insecure profile of the servlet sample); same with basic auth
  • Webflux or Servlet application: Servlet

Client information

  • Spring Boot versions: any, not client-related
  • Used discovery mechanism: self registration
  • Webflux or Servlet application: Servlet

Description

Since 4.1.3, views that a UI extension registers via SBA.viewRegistry.addView(...) or SBA.use({ install({ viewRegistry }) { ... } }) are added to the registry, but no route is created for them. The browser console shows:

TypeError: Cannot read properties of undefined (reading 'startsWith')

Top-level extension views disappear from the navbar, and instance views are missing from the sidebar. 4.1.2 works.

Reproduce with the bundled sample: run spring-boot-admin-sample-servlet, which includes spring-boot-admin-sample-custom-ui, with the insecure profile. On 4.1.3 the "My Extensions" navbar entry and the "Custom" instance view are gone, and the console shows the error above.

Screenshots and recordings (4.1.3 vs. 4.1.3 + fix) are attached in the first comment.

Our own extension registers instance views like this and is affected the same way:

SBA.viewRegistry.addView({
  name: 'instances/acme-caches',
  parent: 'instances',
  path: 'acme-caches',
  component: Caches,
  label: 'Caches',
  group: 'acme',
  order: 1002,
  isEnabled: ({ instance }) => instance.hasEndpoint('acme-caches'),
});

Cause: #5542 made ViewRegistry._addView async, so ViewRegistry.addView now returns Promise<SbaView>[]. useViewRegistry().addView (which is what SBA.viewRegistry exposes) still treats the result as views:

const view = viewRegistry.addView(viewToAdd)[0]; // a Promise now
...
ensureAbsolutePath(view.path) // view.path === undefined -> throws

That branch only runs once the router exists. Extension scripts are appended as <script> tags in index.ts and run after createRouter(), so every extension view goes through it. _addView itself never awaits anything; only isEnabled needs to accept a promise.

I have a fix with a regression test ready and will open a PR.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions