{"record":{"id":"f2b675a8231b4540","repo":"apify/crawlee","slug":"unsupported-format-format-use-one-of-supp","errorCode":null,"errorMessage":"Unsupported format: '${format}'. Use one of ${supportedFormats.join(', ')}","messagePattern":"Unsupported format: '(.+?)'\\. Use one of (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/basic-crawler/src/internals/basic-crawler.ts","lineNumber":2270,"sourceCode":"     * Retrieves all the data from the default crawler {@apilink Dataset} and exports them to the specified format.\n     * Supported formats are currently 'json' and 'csv', and will be inferred from the `path` automatically.\n     */\n    async exportData<Data>(path: string, format?: 'json' | 'csv', options?: DatasetExportOptions): Promise<Data[]> {\n        const supportedFormats = ['json', 'csv'];\n\n        const formatMatch = /\\.(json|csv)$/i.exec(path);\n        if (!format && formatMatch) {\n            format = formatMatch[1].toLowerCase() as 'json' | 'csv';\n        }\n\n        if (!format) {\n            throw new Error(\n                `Failed to infer format from the path: '${path}'. Supported formats: ${supportedFormats.join(', ')}`,\n            );\n        }\n\n        if (!supportedFormats.includes(format)) {\n            throw new Error(`Unsupported format: '${format}'. Use one of ${supportedFormats.join(', ')}`);\n        }\n\n        const dataset = await this.getDataset();\n        const items = await dataset.export(options);\n\n        if (format === 'csv') {\n            let value: string;\n            if (items.length === 0) {\n                value = '';\n            } else {\n                const keys = options?.collectAllKeys\n                    ? Array.from(new Set(items.flatMap(Object.keys)))\n                    : Object.keys(items[0]);\n\n                const { stringify } = await import('csv-stringify/sync');\n\n                value = stringify([\n                    keys,","sourceCodeStart":2252,"sourceCodeEnd":2288,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/basic-crawler/src/internals/basic-crawler.ts#L2252-L2288","documentation":"When an explicit format is provided (or inferred from the path extension), BasicCrawler validates it against the list of supported formats (json, csv). If the format is not supported, this error is thrown naming the valid choices.","triggerScenarios":"Passing a format option such as 'xml', 'xlsx', 'ndjson', or 'JSONL' to the dataset export call, or an explicit format that doesn't match 'json' or 'csv'.","commonSituations":"Users assuming Excel/NDJSON export is supported; passing uppercase 'JSON' while supportedFormats comparison is case-sensitive; copying options from other data libraries.","solutions":["Use 'json' or 'csv' as the format value","If you need another format, export as JSON and convert afterwards with your own code","Check the casing of the format string (it must match the supported list, e.g. lowercase 'csv')"],"exampleFix":"// before\nawait crawler.exportTo('data.xml', { format: 'xml' });\n// after\nawait crawler.exportTo('data.json', { format: 'json' });","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['json','csv'];\nif (format && !SUPPORTED.includes(format.toLowerCase())) throw new Error(`Unsupported format ${format}; use json or csv`);","typeGuard":null,"tryCatchPattern":"try { await crawler.exportTo(p, { format }); } catch (e) { if (String(e.message).startsWith('Unsupported format')) { /* retry with 'json' */ } else throw e; }","preventionTips":["Hardcode only 'json' or 'csv' as format values","Centralize export options in a constant to avoid typos/casing mistakes"],"tags":["configuration","dataset-export","validation"],"backgroundTag":"unsupported-export-format","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}