Skip to content

Commit

Permalink
Merge pull request #2776 from lpsinger/404-nan
Browse files Browse the repository at this point in the history
Raise 404, not 500, if circularId is not finite
  • Loading branch information
dakota002 authored Dec 11, 2024
2 parents 05c0611 + ed63237 commit c7607d5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/routes/circulars/circulars.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ export async function get(
circularId: number,
version?: number
): Promise<Circular> {
if (isNaN(circularId) || (version !== undefined && isNaN(version)))
throw new Response(null, { status: 404 })
const circularVersions = await getDynamoDBVersionAutoIncrement(circularId)
const result = await circularVersions.get(version)
if (!result)
Expand Down Expand Up @@ -367,6 +369,7 @@ export async function putVersion(
* @returns an array of previous versions of a Circular sorted by version
*/
export async function getVersions(circularId: number): Promise<number[]> {
if (isNaN(circularId)) throw new Response(null, { status: 404 })
const circularVersionsAutoIncrement =
await getDynamoDBVersionAutoIncrement(circularId)
return await circularVersionsAutoIncrement.list()
Expand Down

0 comments on commit c7607d5

Please sign in to comment.