Skip to content

Commit da1031e

Browse files
waleedlatif1claude
andcommitted
fix(manageengine): reject JSON-array response bodies
A 2xx body that parses to an array passed the `typeof 'object'` check, so it was accepted as a v3 envelope. It carries no `response_status`, so a list read as empty and a delete reported success. Reject arrays and `null` alongside the scalar case already handled. Also name the display_id children in its description — the docs generator renders one level of output nesting repo-wide, so the shape is otherwise invisible on the page. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HbUGaP3XyrSm3Lk3k959j2
1 parent 9ac6b7e commit da1031e

5 files changed

Lines changed: 43 additions & 19 deletions

File tree

‎apps/docs/content/docs/integrations/manageengine_sdp.mdx‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ Create a problem record in ManageEngine ServiceDesk Plus Cloud with a title, des
415415
| --------- | ---- | ----------- |
416416
| `problem` | object | The created problem |
417417
| ↳ `id` | string | Problem ID |
418-
| ↳ `display_id` | json | Problem number shown in the SDP UI |
418+
| ↳ `display_id` | json | Problem number shown in the SDP UI \(display_value, value\) |
419419
| ↳ `title` | string | Problem title |
420420
| ↳ `description` | string | Problem description \(HTML\) |
421421
| ↳ `status` | json | Current status |
@@ -455,7 +455,7 @@ Retrieve a single ManageEngine ServiceDesk Plus Cloud problem by ID.
455455
| --------- | ---- | ----------- |
456456
| `problem` | object | The problem |
457457
| ↳ `id` | string | Problem ID |
458-
| ↳ `display_id` | json | Problem number shown in the SDP UI |
458+
| ↳ `display_id` | json | Problem number shown in the SDP UI \(display_value, value\) |
459459
| ↳ `title` | string | Problem title |
460460
| ↳ `description` | string | Problem description \(HTML\) |
461461
| ↳ `status` | json | Current status |
@@ -501,7 +501,7 @@ List ManageEngine ServiceDesk Plus Cloud problems, with optional search criteria
501501
| --------- | ---- | ----------- |
502502
| `problems` | array | Matching problems |
503503
| ↳ `id` | string | Problem ID |
504-
| ↳ `display_id` | json | Problem number shown in the SDP UI |
504+
| ↳ `display_id` | json | Problem number shown in the SDP UI \(display_value, value\) |
505505
| ↳ `title` | string | Problem title |
506506
| ↳ `description` | string | Problem description \(HTML\) |
507507
| ↳ `status` | json | Current status |
@@ -563,7 +563,7 @@ Update a ManageEngine ServiceDesk Plus Cloud problem: change its title, status,
563563
| --------- | ---- | ----------- |
564564
| `problem` | object | The updated problem |
565565
| ↳ `id` | string | Problem ID |
566-
| ↳ `display_id` | json | Problem number shown in the SDP UI |
566+
| ↳ `display_id` | json | Problem number shown in the SDP UI \(display_value, value\) |
567567
| ↳ `title` | string | Problem title |
568568
| ↳ `description` | string | Problem description \(HTML\) |
569569
| ↳ `status` | json | Current status |
@@ -699,7 +699,7 @@ Create a change record in ManageEngine ServiceDesk Plus Cloud with a title, stag
699699
| --------- | ---- | ----------- |
700700
| `change` | object | The created change |
701701
| ↳ `id` | string | Change ID |
702-
| ↳ `display_id` | json | Change number shown in the SDP UI |
702+
| ↳ `display_id` | json | Change number shown in the SDP UI \(display_value, value\) |
703703
| ↳ `title` | string | Change title |
704704
| ↳ `description` | string | Change description \(HTML\) |
705705
| ↳ `status` | json | Current status |
@@ -742,7 +742,7 @@ Retrieve a single ManageEngine ServiceDesk Plus Cloud change by ID.
742742
| --------- | ---- | ----------- |
743743
| `change` | object | The change |
744744
| ↳ `id` | string | Change ID |
745-
| ↳ `display_id` | json | Change number shown in the SDP UI |
745+
| ↳ `display_id` | json | Change number shown in the SDP UI \(display_value, value\) |
746746
| ↳ `title` | string | Change title |
747747
| ↳ `description` | string | Change description \(HTML\) |
748748
| ↳ `status` | json | Current status |
@@ -791,7 +791,7 @@ List ManageEngine ServiceDesk Plus Cloud changes, with optional search criteria,
791791
| --------- | ---- | ----------- |
792792
| `changes` | array | Matching changes |
793793
| ↳ `id` | string | Change ID |
794-
| ↳ `display_id` | json | Change number shown in the SDP UI |
794+
| ↳ `display_id` | json | Change number shown in the SDP UI \(display_value, value\) |
795795
| ↳ `title` | string | Change title |
796796
| ↳ `description` | string | Change description \(HTML\) |
797797
| ↳ `status` | json | Current status |
@@ -861,7 +861,7 @@ Update a ManageEngine ServiceDesk Plus Cloud change: move its stage or status, r
861861
| --------- | ---- | ----------- |
862862
| `change` | object | The updated change |
863863
| ↳ `id` | string | Change ID |
864-
| ↳ `display_id` | json | Change number shown in the SDP UI |
864+
| ↳ `display_id` | json | Change number shown in the SDP UI \(display_value, value\) |
865865
| ↳ `title` | string | Change title |
866866
| ↳ `description` | string | Change description \(HTML\) |
867867
| ↳ `status` | json | Current status |
@@ -1224,7 +1224,7 @@ Add an article to the ManageEngine ServiceDesk Plus Cloud knowledge base under a
12241224
| --------- | ---- | ----------- |
12251225
| `solution` | object | The created solution |
12261226
| ↳ `id` | string | Solution ID |
1227-
| ↳ `display_id` | json | Solution number shown in the SDP UI |
1227+
| ↳ `display_id` | json | Solution number shown in the SDP UI \(display_value, value\) |
12281228
| ↳ `title` | string | Solution title |
12291229
| ↳ `description` | string | Solution body \(HTML\) |
12301230
| ↳ `topic` | json | Topic the solution is filed under |
@@ -1261,7 +1261,7 @@ Retrieve a single ManageEngine ServiceDesk Plus Cloud knowledge base solution by
12611261
| --------- | ---- | ----------- |
12621262
| `solution` | object | The solution |
12631263
| ↳ `id` | string | Solution ID |
1264-
| ↳ `display_id` | json | Solution number shown in the SDP UI |
1264+
| ↳ `display_id` | json | Solution number shown in the SDP UI \(display_value, value\) |
12651265
| ↳ `title` | string | Solution title |
12661266
| ↳ `description` | string | Solution body \(HTML\) |
12671267
| ↳ `topic` | json | Topic the solution is filed under |
@@ -1304,7 +1304,7 @@ Search the ManageEngine ServiceDesk Plus Cloud knowledge base, with optional sea
13041304
| --------- | ---- | ----------- |
13051305
| `solutions` | array | Matching solutions |
13061306
| ↳ `id` | string | Solution ID |
1307-
| ↳ `display_id` | json | Solution number shown in the SDP UI |
1307+
| ↳ `display_id` | json | Solution number shown in the SDP UI \(display_value, value\) |
13081308
| ↳ `title` | string | Solution title |
13091309
| ↳ `description` | string | Solution body \(HTML\) |
13101310
| ↳ `topic` | json | Topic the solution is filed under |
@@ -1356,7 +1356,7 @@ Update a ManageEngine ServiceDesk Plus Cloud knowledge base solution: revise its
13561356
| --------- | ---- | ----------- |
13571357
| `solution` | object | The updated solution |
13581358
| ↳ `id` | string | Solution ID |
1359-
| ↳ `display_id` | json | Solution number shown in the SDP UI |
1359+
| ↳ `display_id` | json | Solution number shown in the SDP UI \(display_value, value\) |
13601360
| ↳ `title` | string | Solution title |
13611361
| ↳ `description` | string | Solution body \(HTML\) |
13621362
| ↳ `topic` | json | Topic the solution is filed under |

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/manageengine_sdp/types.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export const SDP_PROBLEM_PROPERTIES: Record<string, ToolOutputProperty> = {
510510
id: { type: 'string', description: 'Problem ID' },
511511
display_id: {
512512
type: 'json',
513-
description: 'Problem number shown in the SDP UI',
513+
description: 'Problem number shown in the SDP UI (display_value, value)',
514514
optional: true,
515515
nullable: true,
516516
properties: DISPLAY_ID_PROPERTIES,
@@ -648,7 +648,7 @@ export const SDP_CHANGE_PROPERTIES: Record<string, ToolOutputProperty> = {
648648
id: { type: 'string', description: 'Change ID' },
649649
display_id: {
650650
type: 'json',
651-
description: 'Change number shown in the SDP UI',
651+
description: 'Change number shown in the SDP UI (display_value, value)',
652652
optional: true,
653653
nullable: true,
654654
properties: DISPLAY_ID_PROPERTIES,
@@ -917,7 +917,7 @@ export const SDP_SOLUTION_PROPERTIES: Record<string, ToolOutputProperty> = {
917917
id: { type: 'string', description: 'Solution ID' },
918918
display_id: {
919919
type: 'json',
920-
description: 'Solution number shown in the SDP UI',
920+
description: 'Solution number shown in the SDP UI (display_value, value)',
921921
optional: true,
922922
nullable: true,
923923
properties: DISPLAY_ID_PROPERTIES,

‎apps/sim/tools/manageengine_sdp/utils.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,24 @@ describe('parseSdpResponse', () => {
259259
await expect(parseSdpResponse(scalar, 'Failed to get request')).rejects.toThrow(/non-JSON/)
260260
})
261261

262+
it('throws on a 2xx JSON array, which is typeof object but not a v3 envelope', async () => {
263+
// An array carries no `response_status`, so accepting it would read as a
264+
// successful empty list and as a successful delete.
265+
const array = new Response('[]', {
266+
status: 200,
267+
headers: { 'Content-Type': 'application/json' },
268+
})
269+
await expect(parseSdpResponse(array, 'Failed to list requests')).rejects.toThrow(/non-JSON/)
270+
})
271+
272+
it('throws on a 2xx `null` body', async () => {
273+
const nul = new Response('null', {
274+
status: 200,
275+
headers: { 'Content-Type': 'application/json' },
276+
})
277+
await expect(parseSdpResponse(nul, 'Failed to get request')).rejects.toThrow(/non-JSON/)
278+
})
279+
262280
it('tolerates an empty 2xx body, which carries nothing this layer needs', async () => {
263281
// `null` rather than `''`: the Response constructor rejects a 204 with a body.
264282
const noContent = new Response(null, { status: 204 })

‎apps/sim/tools/manageengine_sdp/utils.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,15 @@ export async function parseSdpResponse(
210210
let malformed = false
211211
if (text.trim()) {
212212
try {
213-
const parsed = JSON.parse(text)
214-
data = parsed && typeof parsed === 'object' ? (parsed as Record<string, unknown>) : {}
215-
malformed = data !== parsed
213+
const parsed: unknown = JSON.parse(text)
214+
// An array is `typeof 'object'` but is not a v3 envelope: it carries no
215+
// `response_status`, so it would read as a successful empty result. Scalars
216+
// and null are rejected for the same reason.
217+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
218+
data = parsed as Record<string, unknown>
219+
} else {
220+
malformed = true
221+
}
216222
} catch {
217223
malformed = true
218224
}

0 commit comments

Comments
 (0)