Data verification between services in microservices

does the data validation of services between microservices need to be checked every time, or can certain data errors be tolerated?

< H2 > description < / H2 >

Service A user module
Service B comment module

< H2 > problem description < / H2 >

Service B needs user-to-user ID user name and other basic user information when creating comments, which are passed to the background through the foreground as parameters. However, is it necessary to verify the existence of this user through user ID to Service A during creation? Or insert it directly into the database without verification? This will result in the possibility that the current user does not exist in the system, but can create comments, resulting in wrong data in the comment system? How to deal with this situation?


when you write a series of functions, probably not every function will check whether the parameters are in line with the context of this function, because this function can be considered to be passed from the previous function to the last function.
whether service B needs to validate all parameters depends on whether service B is an internal service or an external service, and whether it deals directly with the client. If so, there must be a perfect verification; if not, it depends on whether the previous service has been fully verified, and whether multiple business systems need to use this service.

Menu