Standard Response for handle Not Found / Null?

Background

Some of our API’s return 404’s for Not Found or Null. Unfortunately, our APM systems see all 400+ status codes as errors, so these response are creating a lot of noise in error logs. So, we want to have a conversation around “What should be returned when we can’t find a record in a database?”

Prior Discussions

  •  

https://ucsbtech.slack.com/archives/C65HP27B5/p1619459661008000

What are we currently doing?

null values

ARIT

SA

null values

ARIT

SA

Notes

 

We just used whatever Microsoft had as their default implementation

Single Value

200 - {}

200 - null

List Value

200 - []

200 - []

Discussion

 

  • The diference in the Single Values comes down to the approaches each group is doing in their domain models.

    • In ARIT, they are always trying to keep the same “object shape”. So, if a function is supposed to return a Person object, then it must return either a populated Person object or a Person.Empty object.

    • In SA, they return null when a record isn’t found in the database. So, their functions can return a Person object or null.

  • Gary

    • If we make any changes to any API’s, then we would bump the major version number and implement the new return types on that.

    • At some point in the future, I think it would be good to revisit the Fusion API because it’s returning a lot of data, when we only need a little (just the changes)