Skip to content

Commit 5d8814e

Browse files
committed
fix(workday): coerce compensation amounts and guard Date marshaling
- get-compensation returned Amount/Per_Unit_Amount/Individual_Target_Amount as strings (XML leaf text), violating the tool's number contract - Coerce via parseSoapNumber and widen plan type to number | string - Add defensive Date branch in marshal() so Date inputs serialize as ISO 8601 instead of String(date)
1 parent a25b149 commit 5d8814e

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

apps/sim/app/api/tools/workday/get-compensation/route.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
createWorkdaySoapClient,
1010
extractRefId,
1111
normalizeSoapArray,
12+
parseSoapNumber,
1213
type WorkdayCompensationDataSoap,
1314
type WorkdayCompensationPlanSoap,
1415
type WorkdayWorkerSoap,
@@ -60,7 +61,11 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
6061
const mapPlan = (p: WorkdayCompensationPlanSoap) => ({
6162
id: extractRefId(p.Compensation_Plan_Reference) ?? null,
6263
planName: p.Compensation_Plan_Reference?.attributes?.Descriptor ?? null,
63-
amount: p.Amount ?? p.Per_Unit_Amount ?? p.Individual_Target_Amount ?? null,
64+
amount:
65+
parseSoapNumber(p.Amount) ??
66+
parseSoapNumber(p.Per_Unit_Amount) ??
67+
parseSoapNumber(p.Individual_Target_Amount) ??
68+
null,
6469
currency: extractRefId(p.Currency_Reference) ?? null,
6570
frequency: extractRefId(p.Frequency_Reference) ?? null,
6671
})

apps/sim/tools/workday/soap.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ export interface WorkdayCompensationDataSoap {
7979

8080
export interface WorkdayCompensationPlanSoap {
8181
Compensation_Plan_Reference?: WorkdayReference
82-
Amount?: number
83-
Per_Unit_Amount?: number
84-
Individual_Target_Amount?: number
82+
Amount?: number | string
83+
Per_Unit_Amount?: number | string
84+
Individual_Target_Amount?: number | string
8585
Currency_Reference?: WorkdayReference
8686
Frequency_Reference?: WorkdayReference
8787
}
@@ -246,6 +246,10 @@ function marshal(name: string, value: unknown): string {
246246
return out
247247
}
248248

249+
if (value instanceof Date) {
250+
return `<${tag}>${value.toISOString()}</${tag}>`
251+
}
252+
249253
if (typeof value === 'object') {
250254
const obj = value as Record<string, unknown>
251255
const attrs = obj.attributes as Record<string, string> | undefined

0 commit comments

Comments
 (0)