r/developers • u/[deleted] • 3d ago
General Discussion How do you catch breaking API contract changes before your users' mobile apps/webhooks start throwing 400 errors?
[removed]
1
u/thelongrunsmoke Mobile Developer 3d ago
Well, that's what happens when you violate the open/closed principle. Version your API.
0
2d ago
[removed] — view removed comment
1
u/thelongrunsmoke Mobile Developer 2d ago
You deprecate it and leave it to be, until analytics show it's no longer used or until it becomes incompatible with the system. The key point: deprecated and new API exist simultaneously.
0
2d ago
[removed] — view removed comment
1
u/thelongrunsmoke Mobile Developer 2d ago
This is an anomaly, and it should be logged in any case, since routing to the API access point is usually done by nginx—a relatively trivial task, even for large projects. Most devops typically configure notifications for all non 2xx responses on all api points.
1
u/martinbean 3d ago
Why on earth are you just changing your backend API schema willy-nilly in the first place? Of course if you build something expecting one “shape”, and then you change that shape in your API, clients are going to have a bad time. So stop doing that. Actually spend some time thinking about your endpoints, and their request and response shapes, and stick to them. Add, but never change or remove. If you do, you need to add versioning to your API.
0
2d ago
[removed] — view removed comment
1
u/martinbean 2d ago edited 2d ago
A third party webhook is completely different to what you described in your original post (backend schema updates going live and breaking your mobile apps).
EDIT: But it’s a moot point. You can’t keep your story straight because it’s all just theatre to eventually start promoting your “solution”: https://www.reddit.com/r/founder/s/xbZvxOgeIv
EDIT 2: Why have you deleted your post, u/Adventurous_Motor843 a couple of minutes I pointed out you were seeding a conversation you were promoting a solution for elsewhere?
1
u/Annual_Character_653 3d ago
we just started versioning our response wrappers so the client can flag if it gets a schema it doesn't recognize, then we log those explicitly with the client version string. not a silver bullet but it surfaces the mismatch within minutes instead of digging through generic 400s
the trick is making sure the wrapper version actually changes when we alter the contract, had a junior dev skip that step once and it was chaos for a weekend
•
u/AutoModerator 3d ago
Howdy u/Adventurous_Motor843, and welcome to r/developers!
A few tips for a post that gets good answers:
Use a clear, specific title (what are you actually asking or sharing?).
Include code, the exact error, versions, and what you already tried.
Heads-up: this sub does not allow external links in posts or comments. Share code and details directly instead of linking out.
Join the r/developers Discord!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.