QueryFailedError Postgres malformed array literal "checkin,checkout", AWS serverless

Viewed 20

Payload:

{"name":"test","actions":["checkin","checkout"],"statuses":["approved","invited","chargeback_settled","activated","payment_required","registered","free"]}

Attribute of entity:

 @JoiSchema(Joi.array().items(Joi.string()))
  @Column({ type: 'simple-array', array: true })
  actions?: string[];

This works in our integration tests:

  const obj: Project = await projectsService.create({
  name: 'MyProject',
  actions: ['action1', 'action2'],
  statuses: ['status1', 'status2'],
  tenant_id: tenant_id,
});

It also works in end to end tests.

If however POSTed via Frontend with aboves exact payload it produces this error in Cloudwatch:


QueryFailedError: malformed array literal: "checkin,checkout"

Any clue as to why?

1 Answers

  @JoiSchema(Joi.array().items(Joi.string()))
  @Column('simple-array', { nullable: true })
  actions?: string[];

Changing the column annotation to this has fixed it, for anyone else having the problem.

The issue however, is STILL NOT reproducable via end to end tests or god forbid even integration tests.

So this issue only arises from a call from an actual other application context, only god knows why. Anyhow, this fixes it.

Related