PhilanthropyDataCommons / service

A project for collecting and serving public information associated with grant applications
GNU Affero General Public License v3.0
8 stars 2 forks source link

Make the maximum ID value explicit for ID parameters #971

Closed slifty closed 2 months ago

slifty commented 4 months ago

I tried GET opportunities/555555555555555555555555555555 and got this response:

{
  "name": "DatabaseError",
  "message": "Unexpected database error.",
  "details": [
    {
      "length": 168,
      "name": "error",
      "severity": "ERROR",
      "code": "22003",
      "where": "unnamed portal parameter $1 = '...'",
      "file": "numutils.c",
      "line": "314",
      "routine": "pg_strtoint32"
    }
  ]
}

Which is fine and probably not a new error at all, but would be nice to make it a 400 since we don't support IDs greater than 2^32-1.

_Originally posted by @bickelj in https://github.com/PhilanthropyDataCommons/service/pull/967#discussion_r1583490515_

We can easily add this to the isId validator function which should harden all our endpoints at once.