mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(cli): Account for unparseable string in JSON key migration (#3927)
⚡ Account for unparseable string in JSON key migration
This commit is contained in:
parent
f22bd2805d
commit
ab45898a69
|
@ -64,8 +64,17 @@ export const addJsonKeyToPinDataColumn =
|
|||
function makeUpdateParams(fetchedWorkflows: PinData.FetchedWorkflow[]) {
|
||||
return fetchedWorkflows.reduce<PinData.FetchedWorkflow[]>(
|
||||
(updateParams, { id, pinData: rawPinData }) => {
|
||||
const pinDataPerWorkflow: PinData.Old | PinData.New =
|
||||
typeof rawPinData === 'string' ? JSON.parse(rawPinData) : rawPinData;
|
||||
let pinDataPerWorkflow: PinData.Old | PinData.New;
|
||||
|
||||
if (typeof rawPinData === 'string') {
|
||||
try {
|
||||
pinDataPerWorkflow = JSON.parse(rawPinData);
|
||||
} catch (_) {
|
||||
pinDataPerWorkflow = {};
|
||||
}
|
||||
} else {
|
||||
pinDataPerWorkflow = rawPinData;
|
||||
}
|
||||
|
||||
const newPinDataPerWorkflow = Object.keys(pinDataPerWorkflow).reduce<PinData.New>(
|
||||
(newPinDataPerWorkflow, nodeName) => {
|
||||
|
|
|
@ -5,7 +5,7 @@ export namespace PinData {
|
|||
|
||||
export type New = { [nodeName: string]: INodeExecutionData[] };
|
||||
|
||||
export type FetchedWorkflow = { id: number; pinData: string | object };
|
||||
export type FetchedWorkflow = { id: number; pinData: string | Old };
|
||||
}
|
||||
|
||||
export function isObjectLiteral(maybeObject: unknown): maybeObject is { [key: string]: string } {
|
||||
|
|
Loading…
Reference in a new issue