Page Contents

In order to allow clients to reliably detect individual error causes, LoopBack sets the error code property to a machine-readable string.


The entity (model) was not found. This error is returned for example by EntityCrudRepository.prototype.findById.


The data provided by the client is not a valid entity.


The value provided for a parameter of a REST endpoint is not valid. For example, a string value was provided for a numeric parameter.


No value was provided for a required parameter.


LoopBack is using TypeScript design-time type metadata to automatically infer simple property types like string, number or a model class.

In the following example, the type of the property name is inferred from TypeScript metadata as string.

class Product {
  name: string;

Design-time property type is not available in the following cases:

  • The property has a type not supported by TypeScript metadata engine:
    • undefined
    • null
    • complex types like arrays (string[]), generic types (Partial<MyModel>), union types (string | number), and more.
  • The TypeScript project has not enabled the compiler option emitDecoratorMetadata.
  • The code is written in vanilla JavaScript.


You have the following options how to fix the error CANNOT_INFER_PROPERTY_TYPE:

  1. If you are using TypeScript, make sure emitDecoratorMetadata is enabled in your compiler options.

      "$schema": "",
      "compilerOptions": {
        "emitDecoratorMetadata": true

    A typical LoopBack project is inheriting compiler options from @loopback/build, where emitDecoratorMetadata is already enabled.

      "$schema": "",
      "extends": "@loopback/build/config/tsconfig.common.json"
  2. If your property uses a complex type, then specify the type in the type field of @property() definition.

    class UserProfile {
      @property({type: 'string'})
      hourFormat: '12h' | '24h';

Other error codes

Besides LoopBack-specific error codes, your application can encounter low-level error codes from Node.js and the underlying operating system. For example, when a connector is not able to reach the database, an error with code ECONNREFUSED is returned.

See the following resources for a list of low-level error codes: