booster icon indicating copy to clipboard operation
booster copied to clipboard

Error: cannot read property 'name' of null

Open MichaelHirn opened this issue 4 years ago • 1 comments

Bug Report

Current Behavior

  1. boost start -e local -p 3001
  2. submitting a command
senderClient.mutate({
  variables: recordA,
  mutation: gql
  mutation RecordCreate($recordId: ID, $recordRefs: [JSONObject!]) {
    RecordCreate(
      input: {
        recordId: $recordId,
        recordRefs: $recordRefs,
      })
   },
 }),
  1. server crashes and throws generic error (see below); no other output, no logs, nothing

Expected behavior

Descriptive error message or no error

Additional information

~~I'm trying to figure out how to reproduce this, but I'm not sure yet what/where the issue is here~~

Update: see how to reproduce below

Error stack trace

❯ boost start -e local -p 3001
ℹ boost debug [local] 🐛
✔ Starting debug server on port 3001
TypeError: Cannot read property 'name' of null
    at GraphQLTypeInformer.getGraphQLTypeFor (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-type-informer.js:73:50)
    at GraphQLQueryGenerator.generateFilterFor (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:224:55)
    at GraphQLQueryGenerator.generateFilterFor (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:232:70)
    at ./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:181:28
    at Array.forEach (<anonymous>)
    at GraphQLQueryGenerator.generateFilterArguments (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:179:33)
    at GraphQLQueryGenerator.generateFilterQueriesFields (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:148:38)
    at GraphQLQueryGenerator.generateFilterQueries (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:71:28)
    at GraphQLQueryGenerator.generate (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-query-generator.js:20:36)
    at Function.generateSchema (./node_modules/@boostercloud/framework-core/dist/services/graphql/graphql-generator.js:27:39)
    at new BoosterGraphQLDispatcher (./node_modules/@boostercloud/framework-core/dist/booster-graphql-dispatcher.js:18:67)
    at Function.serveGraphQL (./node_modules/@boostercloud/framework-core/dist/booster.js:102:16)
    at Object.boosterServeGraphQL (./node_modules/@boostercloud/framework-core/dist/booster.js:129:20)
    at GraphQLService.handleGraphQLRequest (./node_modules/@boostercloud/framework-provider-local/dist/services/graphql-service.js:9:35)
    at GraphQLController.handleGraphQL (./node_modules/@boostercloud/framework-provider-local-infrastructure/dist/controllers/graphql.js:14:56)
    at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
    at next (./node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (./node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
    at ./node_modules/express/lib/router/index.js:281:22
    at Function.process_params (./node_modules/express/lib/router/index.js:341:12)
    at next (./node_modules/express/lib/router/index.js:275:10)
    at Function.handle (./node_modules/express/lib/router/index.js:174:3)
    at router (./node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (./node_modules/express/lib/router/index.js:323:13)
    at ./node_modules/express/lib/router/index.js:284:7
    at Function.process_params (./node_modules/express/lib/router/index.js:341:12)
    at next (./node_modules/express/lib/router/index.js:275:10)
    at Function.handle (./node_modules/express/lib/router/index.js:174:3)
    at router (./node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (./node_modules/express/lib/router/index.js:323:13)
    at ./node_modules/express/lib/router/index.js:284:7
    at Function.process_params (./node_modules/express/lib/router/index.js:341:12)
    at next (./node_modules/express/lib/router/index.js:275:10)
    at ./node_modules/@boostercloud/framework-provider-local-infrastructure/dist/index.js:56:17
    at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (./node_modules/express/lib/router/index.js:323:13)
    at ./node_modules/express/lib/router/index.js:284:7
    at Function.process_params (./node_modules/express/lib/router/index.js:341:12)
    at next (./node_modules/express/lib/router/index.js:275:10)
    at cors (./node_modules/cors/lib/index.js:188:7)
    at ./node_modules/cors/lib/index.js:224:17
    at originCallback (./node_modules/cors/lib/index.js:214:15)
    at ./node_modules/cors/lib/index.js:219:13
    at optionsCallback (./node_modules/cors/lib/index.js:199:9)
    at corsMiddleware (./node_modules/cors/lib/index.js:204:7)
    at Layer.handle [as handle_request] (./node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (./node_modules/express/lib/router/index.js:323:13)
    at ./node_modules/express/lib/router/index.js:284:7
    at Function.process_params (./node_modules/express/lib/router/index.js:341:12)
    at next (./node_modules/express/lib/router/index.js:275:10)
    at ./node_modules/body-parser/lib/read.js:130:5
    at invokeCallback (./node_modules/raw-body/index.js:224:16)
    at done (./node_modules/raw-body/index.js:213:7)
    at IncomingMessage.onEnd (./node_modules/raw-body/index.js:273:7)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Environment

  • Booster version: @boostercloud/cli/0.24.2 darwin-x64 node-v14.18.1 ([email protected])
  • OS: OSX 12.1

MichaelHirn avatar Jan 29 '22 21:01 MichaelHirn

Ok, I think I found the cause for this error and should be reproducible now. In short:

The Cause

We have one entity (Order) and two read models (OrdersByOwner, OrderByAsk)

OrdersByOwner (✅ this is fine: Order[])

@ReadModel
export class OrdersByOwner {
  public constructor(
    public id: UUID,
    readonly orders: Order[]
  ) {}
}

OrderByAsk (❌ this is not fine: Order)

@ReadModel
export class OrderByAsk {
  public constructor(
    public id: UUID,
    readonly order: Order
  ) {}
}

Order (just for completion sake)

@Entity
export class Order {
  public constructor(
    public id: UUID,
    readonly ownerId: UUID,
    readonly type: 'reference',
    readonly createdAt: number,
    readonly isExpired: boolean,
    readonly ask?: UUID,
    readonly bid?: UUID
  ) {}
}

=> an array of the entity works fine but just the entity is causing the above error

Update

To confirm, if we slightly change OrderByAsk and wrap into an array it all seems to work

OrderByAsk (✅ this is fine now: [Order])

@ReadModel
export class OrderByAsk {
  public constructor(
    public id: UUID,
    readonly order: [Order]
  ) {}
}

MichaelHirn avatar Jan 29 '22 21:01 MichaelHirn