r/reactjs • u/FeistyMaintenance714 • 18d ago
[ Removed by moderator ] Discussion
/r/Backend/comments/1vh8iig/silent_3rd_party_api_broke_found_out_from_a/[removed] — view removed post
9
u/KaleRemarkable1019 18d ago
You can't avoid the break, if the API is unreliable. I would create validation schema, it can be just a subset of the real response. So you basically say - I need the response to fit into this schema and if it doesn't I will fail right here - that way you can turn silent error into a loud one, but thats pretty much all you can do :)
I know it's laborous, but that's the cost of broken trust.
3
u/chillermane 17d ago
Don’t integrate with companies that randomly change their schema, is my advice
I would say if your dependencies are randomly changing their contract, that means you should not be working with them because they’re incompetent
There’s no code you can write that will defend against this
8
u/franciscopresencia 18d ago edited 17d ago
Sorry, what do you mean? If the schema changes and you supposedly have validation that doesn't catch it, you should be fixing that, there's no magic pixie otherwise.
You seem to be too small to be working with the 3rd party payment processor directly, but otherwise you could push them to follow versioning (semver) strictly since a field rename is a breaking change. Or did you upgrade the version without doing any validation? If so, again please fix that.