{"record":{"id":"75296f36b78a9928","repo":"apify/crawlee","slug":"data-item-s-is-not-an-object-you-can-push-only-o","errorCode":null,"errorMessage":"Data item${s}is not an object. You can push only objects into a dataset.","messagePattern":"Data item(.+?)is not an object\\. You can push only objects into a dataset\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storages/dataset.ts","lineNumber":41,"sourceCode":"});\n\n/** @internal */\nexport const DATASET_ITERATORS_DEFAULT_LIMIT = 10000;\n\n/**\n * Validates that the given value is a plain JSON-serializable object\n * (not an array, not a primitive, not circular).\n *\n * @param item The value to validate.\n * @param index Optional index for error messages when validating inside an array.\n * @ignore\n */\nexport function assertJsonSerializable<T>(item: T, index?: number): void {\n    const s = typeof index === 'number' ? ` at index ${index} ` : ' ';\n    const isItemObject = item && typeof item === 'object' && !Array.isArray(item);\n\n    if (!isItemObject) {\n        throw new Error(`Data item${s}is not an object. You can push only objects into a dataset.`);\n    }\n\n    try {\n        JSON.stringify(item);\n    } catch (e) {\n        const err = e as Error;\n        throw new Error(`Data item${s}is not serializable to JSON.\\nCause: ${err.message}`);\n    }\n}\n\nexport interface DatasetDataOptions {\n    /**\n     * Number of array elements that should be skipped at the start.\n     * @default 0\n     */\n    offset?: number;\n\n    /**","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/storages/dataset.ts#L23-L59","documentation":"assertJsonSerializable() (used by Dataset.pushData) rejects any item that is not a non-array object. Datasets store JSON documents, so primitives, arrays, null, and undefined cannot be pushed as items.","triggerScenarios":"pushData(42), pushData('text'), pushData([1,2,3]) (a raw array, though pushData accepts arrays of objects — a nested array element failing), pushData(null), or pushing class instances whose serialization is not a plain object.","commonSituations":"Scrapers accidentally pushing a raw value (e.g. response body string) instead of wrapping it, pushing null when a scrape failed, or pushing mapped arrays containing primitives.","solutions":["Wrap primitives in an object, e.g. { value: item }.","Ensure each array element passed to pushData is an object.","Filter out null/undefined results before pushing.","Convert non-plain objects (Dates, Maps, Sets) to plain JSON objects first."],"exampleFix":"// before\nawait dataset.pushData(price); // number\n\n// after\nawait dataset.pushData({ url: request.url, price });","handlingStrategy":"validation","validationCode":"const isValidItem = (x: unknown): x is Record<string, unknown> =>\n    !!x && typeof x === 'object' && !Array.isArray(x);\nconst items = rawResults.filter(isValidItem);\nawait dataset.pushData(items);","typeGuard":"function isDatasetItem(x: unknown): x is Record<string, unknown> {\n    return typeof x === 'object' && x !== null && !Array.isArray(x);\n}","tryCatchPattern":"try {\n    await dataset.pushData(item);\n} catch (e) {\n    if (e instanceof Error && e.message.includes('not an object')) {\n        await dataset.pushData({ value: item });\n    } else throw e;\n}","preventionTips":["Always push objects; wrap primitives as { key: value }.","Filter null/undefined and non-object entries before pushing.","Type your scrape results as Record<string, unknown> at the source."],"tags":["dataset","validation","json"],"backgroundTag":"invalid-dataset-item","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}