Skip to content

Commit ba0cc05

Browse files
authored
Ellyse/ct 580 gmail and rss importers have failures clean (#1424)
* fixed the path generation when setting array length to 0 * fixed array detection in retry logic * cherrypick bernis change for handling for root writes with value property
1 parent 909239b commit ba0cc05

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/runner/src/data-updating.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export function normalizeAndDiff(
335335
i++
336336
) {
337337
changes.push({
338-
location: { ...link, path: [...link.path, i.toString()] },
338+
location: { ...link, path: [...link.path.slice(0, -1), i.toString()] },
339339
value: undefined,
340340
});
341341
}

packages/runner/src/storage/transaction-shim.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ class TransactionWriter extends TransactionReader
312312
throw new Error(`Failed to get or create document: ${address.id}`);
313313
}
314314

315+
// Rewrite creating new documents as setting the value
316+
if (address.path.length === 0 && isObject(value) && "value" in value) {
317+
address = { ...address, path: ["value"] };
318+
value = value.value;
319+
}
320+
315321
// Path-based logic
316322
if (!address.path.length) {
317323
const notFoundError: INotFoundError = new Error(
@@ -588,7 +594,7 @@ export class ExtendedStorageTransaction implements IExtendedStorageTransaction {
588594
for (const key of remainingPath) {
589595
nextValue =
590596
nextValue[key] =
591-
(typeof Number(key) === "number" ? [] : {}) as typeof nextValue;
597+
(!Number.isNaN(Number(key)) ? [] : {}) as typeof nextValue;
592598
}
593599
nextValue[lastKey] = value;
594600
const parentAddress = { ...address, path: lastValidPath ?? [] };

0 commit comments

Comments
 (0)