Skip to content

Commit 843d665

Browse files
ekremneyclaude
andcommitted
fix: guard createInstanceFromRow against null/undefined input
The all-collections-methods-coverage smoke test invokes every public method including createInstanceFromRow (starts with 'create', treated as mutating). With no args the call reached fromDbRecord(undefined) and threw a TypeError that didn't match the expected-error patterns, failing all 36 collection smoke tests. Add an isNonEmptyObject guard so the method returns null gracefully instead of throwing — consistent with #createInstance's own null-return contract for empty records. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 84c1fd1 commit 843d665

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/spacecat-shared-data-access/src/models/base/base.collection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ class BaseCollection {
595595
* @returns {object|null} A model instance, or null if the row is empty/invalid.
596596
*/
597597
createInstanceFromRow(row) {
598+
if (!isNonEmptyObject(row)) return null;
598599
return this.#createInstance(this.#toModelRecord(row));
599600
}
600601

0 commit comments

Comments
 (0)