Database Error: Postgres Error when calling Strapi Controller method

System Information
  • Strapi Version 3.6.8:
  • Ubuntu Server 20.04:
  • Postgres SQL 13:
  • Node Version 14:
  • NPM Version:
  • Yarn Version:

I have 2 instances of my Strapi API running on a server, a production instance and a staging instance. They are linked to the main branch and staging branch respectively in Git. At this moment, both branches are at the same point in time (same commits). The only difference between the two, is the database that they are pointing to (dev/staging DB vs. prod DB)

I have a Strapi controller method, which retrieves all rows in a specific database table, which is used to generate static pages in our frontend project (Nuxt.js). The controller method is pretty standard - it simply retrieves the records, does a few calculations (currency conversions, etc), strips out unwanted fields, and then returns the modified result. It has worked perfectly for months.

Now, on the production API, I am getting a very strange error message when I do a GET request to that endpoint. In PostMan, I get this error: (Looks to be specific to Postgres)

{
    "length": 104,
    "name": "error",
    "severity": "ERROR",
    "code": "22P02",
    "file": "numutils.c",
    "line": "320",
    "routine": "pg_strtoint32"
}

We are also using the Sentry.io plugin, and we get the following error code there:

error: select "TABLE_NAME".* from "TABLE_NAME" where "TABLE_NAME"."id" = $1 limit $2 - invalid input syntax for type integer: "NaN"

We do NOT get the same error on the Staging API - it returns all of the records as expected.
Does anyone have any insights into what these errors might mean? @DMehaffy

Thanks for your help.

What version of PG are you running?

Postgres 13. Managed DB on Digital Ocean.

Any thoughts on this issue? I has me stumped… @DMehaffy Thanks

At some point it appears you are trying to request data for undefined or you aren’t passing an integer as a lookup.

do you have the code for your controller?

Okay - this particular method isn’t relying on any parameters, other than setting the limit to -1, so that all records are returned.

Can I send you the code for the controller via DM? @DMehaffy Don’t want to post it on a public forum.
Thanks for your help,

Mike

Hello,
are you solved?