From d657a0cb2dfe7e3b0776052788c4df61309fb8ba Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 8 Oct 2026 12:19:24 -0600 Subject: [PATCH] fix: ignore messaging_hook in application create/update (#567) messaging_hook was removed along with smpp (#559), but POST and PUT /Applications still pass the request body straight into the INSERT/UPDATE. Clients that still send messaging_hook (even as null) get a 500: "Unknown column 'messaging_hook' in 'field list'". Drop the field from the request body so older clients keep working. Co-authored-by: Claude Opus 5.5 --- lib/routes/api/applications.js | 4 ++++ test/applications.js | 44 +++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/routes/api/applications.js b/lib/routes/api/applications.js index 1ec0b5a..ea904cb 100644 --- a/lib/routes/api/applications.js +++ b/lib/routes/api/applications.js @@ -150,6 +150,8 @@ router.post('/', async(req, res) => { // create webhooks if provided const obj = Object.assign({}, req.body); + /* messaging_hook was removed along with smpp (#559); ignore it from older clients */ + delete obj.messaging_hook; for (const prop of ['call_hook', 'call_status_hook']) { if (obj[prop]) { obj[`${prop}_sid`] = await Webhook.make(obj[prop]); @@ -285,6 +287,8 @@ router.put('/:sid', async(req, res) => { // create webhooks if provided const obj = Object.assign({}, req.body); + /* messaging_hook was removed along with smpp (#559); ignore it from older clients */ + delete obj.messaging_hook; for (const prop of ['call_hook', 'call_status_hook']) { if (prop in obj && Object.keys(obj[prop]).length) { if ('webhook_sid' in obj[prop]) { diff --git a/test/applications.js b/test/applications.js index 77f8423..5e6e929 100644 --- a/test/applications.js +++ b/test/applications.js @@ -52,7 +52,34 @@ test('application tests', async(t) => { } }); t.ok(result.statusCode === 400, 'Cant create application with invalid app_json'); - + + /* messaging_hook was removed with smpp; older clients that still send it must not fail */ + result = await request.post('/Applications', { + resolveWithFullResponse: true, + simple: false, + auth: authAdmin, + json: true, + body: { + name: 'legacy-client', + account_sid, + call_hook: { + url: 'http://example.com' + }, + call_status_hook: { + url: 'http://example.com/status' + }, + messaging_hook: { + url: 'http://example.com/sms' + } + } + }); + t.ok(result.statusCode === 201, 'messaging_hook is ignored when creating an application'); + result = await request.delete(`/Applications/${result.body.sid}`, { + auth: authAdmin, + resolveWithFullResponse: true, + }); + t.ok(result.statusCode === 204, 'deleted application created with messaging_hook'); + /* add an application */ result = await request.post('/Applications', { resolveWithFullResponse: true, @@ -196,6 +223,21 @@ test('application tests', async(t) => { }); t.ok(result.statusCode === 204, 'successfully updated application'); + /* messaging_hook is ignored on update too */ + result = await request.put(`/Applications/${sid}`, { + auth: authAdmin, + json: true, + resolveWithFullResponse: true, + simple: false, + body: { + name: 'daveh', + messaging_hook: { + url: 'http://example.com/sms' + } + } + }); + t.ok(result.statusCode === 204, 'messaging_hook is ignored when updating an application'); + /* validate app_json was removed */ result = await request.get(`/Applications/${sid}`, { auth: authAdmin,