Skip to content

Commit eb11a09

Browse files
authored
Encode header fields if they exist on schedule edit (#2405)
* Encode header fields if they exist on schedule edit * Add try catch for header fields encoding
1 parent aacf78e commit eb11a09

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: src/lib/stores/schedules.ts

+18
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
ScheduleSpecParameters,
1515
} from '$lib/types/schedule';
1616
import { encodePayloads } from '$lib/utilities/encode-payload';
17+
import { stringifyWithBigInt } from '$lib/utilities/parse-with-big-int';
1718
import { routeForSchedule, routeForSchedules } from '$lib/utilities/route-for';
1819
import {
1920
convertDaysAndMonths,
@@ -204,6 +205,23 @@ export const submitEditSchedule = async (
204205
},
205206
};
206207

208+
const fields = body.schedule.action.startWorkflow?.header?.fields;
209+
if (fields && Object.keys(fields).length > 0) {
210+
try {
211+
const entries = Object.entries(fields);
212+
for (const [key, value] of entries) {
213+
const encodedValue = await encodePayloads(
214+
stringifyWithBigInt(value),
215+
'json/plain',
216+
);
217+
fields[key] = encodedValue[0];
218+
}
219+
} catch (e) {
220+
error.set(`${translate('data-encoder.encode-error')}: ${e?.message}`);
221+
return;
222+
}
223+
}
224+
207225
if (preset === 'existing') {
208226
body.schedule.spec = schedule.spec;
209227
} else {

0 commit comments

Comments
 (0)