Skip to content

[Bug] [router_use_controllers] TypeError: Cannot read properties of undefined (reading 'kind') #385

@valinweb

Description

@valinweb

Addon

No specific addon – This bug report is related to Webtools Core

Describe the bug

Hello,

When using the router and a wrong url is requested, the plugin return a 500 error :
error: Cannot read properties of undefined (reading 'kind') TypeError: Cannot read properties of undefined (reading 'kind') at routerWithControllers (/node_modules/strapi-plugin-webtools/dist/server/index.js:696:57) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Object.router (/node_modules/strapi-plugin-webtools/dist/server/index.js:735:23) at async returnBodyMiddleware (/node_modules/@strapi/core/dist/services/server/compose-endpoint.js:46:20) at async policiesMiddleware (/node_modules/@strapi/core/dist/services/server/policy.js:21:9) at async /node_modules/@strapi/core/dist/services/server/compose-endpoint.js:27:20 at async serve (/node_modules/koa-static/index.js:59:5) at async returnBodyMiddleware (/node_modules/@strapi/core/dist/services/server/compose-endpoint.js:46:20) at async policiesMiddleware (/node_modules/@strapi/core/dist/services/server/policy.js:21:9) at async //node_modules/@strapi/core/dist/services/server/compose-endpoint.js:27:20

Steps to reproduce the behavior

  1. Activate the config option router_use_controllers
  2. Call api/webtools/router?path= with an unknown path

Expected behavior

We should check if strapi.contentTypes[contentType] is existing, instead thow an not found error ?

Screenshots

No response

Code snippets

Node.js version

22.21.1

Package manager

NPM

Strapi version

5.39

Plugin version

1.8.0

Database

MySQL

Operating system

macOS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs investigationThis needs some diving in to before it can be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions