{"record":{"id":"15db979abeac9050","repo":"apify/crawlee","slug":"request-options-are-not-valid-the-url-property","errorCode":null,"errorMessage":"Request options are not valid, the 'url' property is not a string. Input: ${inspect(opts)}","messagePattern":"Request options are not valid, the 'url' property is not a string\\. Input: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/storages/request_queue.ts","lineNumber":598,"sourceCode":"     * @param options Options for the request queue\n     */\n    async addRequestsBatched(\n        requests: ReadonlyDeep<RequestsLike>,\n        options: AddRequestsBatchedOptions = {},\n    ): Promise<AddRequestsBatchedResult> {\n        parseArgument(requests, iterableSchema);\n\n        const { forefront, waitForAllRequestsToBeAdded, batchSize, waitBetweenBatchesMillis, maxNewRequests } =\n            parseArgument(options, addRequestsBatchedOptionsSchema);\n\n        const addRequest = this.addRequest.bind(this);\n\n        async function* generateRequests() {\n            for await (const opts of requests) {\n                // Validate the input\n                if (typeof opts === 'object' && opts !== null) {\n                    if (opts.url !== undefined && typeof opts.url !== 'string') {\n                        throw new Error(\n                            `Request options are not valid, the 'url' property is not a string. Input: ${inspect(opts)}`,\n                        );\n                    }\n\n                    if (opts.id !== undefined) {\n                        throw new Error(\n                            `Request options are not valid, the 'id' property must not be present. Input: ${inspect(opts)}`,\n                        );\n                    }\n\n                    if (\n                        (opts as any).requestsFromUrl !== undefined &&\n                        typeof (opts as any).requestsFromUrl !== 'string'\n                    ) {\n                        throw new Error(\n                            `Request options are not valid, the 'requestsFromUrl' property is not a string. Input: ${inspect(opts)}`,\n                        );\n                    }","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/storages/request_queue.ts#L580-L616","documentation":"RequestQueue.addRequestsBatched() streams inputs through generateRequests(), validating each item. If an object provides a url property that is defined but not a string (number, object, null, array), the library rejects it because Request construction requires a string URL.","triggerScenarios":"Passing an async iterable/array to addRequestsBatched where an item has url: null, url: 123, url: {...}; data from parsed JSON/CSV where url is missing-but-keyed or numeric; TypeScript types bypassed.","commonSituations":"Importing scraped data where the url column is empty/NaN; mapping API responses with inconsistent field types; template objects with url accidentally set to a nested object.","solutions":["Sanitize inputs: keep only items where typeof url === 'string' and non-empty","Coerce valid values (e.g. String(row.url)) and drop invalid rows before adding","Fix upstream data extraction producing non-string urls","Add strict typing/DTO validation (zod etc.) on incoming request sources"],"exampleFix":"// before\nawait requestQueue.addRequestsBatched(rows.map(r => ({ url: r.url }))); // r.url may be null\n// after\nconst valid = rows.filter(r => typeof r.url === 'string' && r.url.length > 0)\n    .map(r => ({ url: r.url }));\nawait requestQueue.addRequestsBatched(valid);","handlingStrategy":"type-guard","validationCode":"const valid = requests.filter(r => !(r && typeof r === 'object' && 'url' in r) || typeof r.url === 'string');","typeGuard":"function hasStringUrl(r) {\n  return r === null || typeof r !== 'object' || r.url === undefined || typeof r.url === 'string';\n}","tryCatchPattern":"try {\n  await queue.addRequestsBatched(requests);\n} catch (err) {\n  if (err.message.includes(\"'url' property is not a string\")) {\n    logger.error(`Invalid request options: ${err.message}`);\n  } else throw err;\n}","preventionTips":["Sanitize/coerce url fields to strings before enqueuing","Validate external data (CSV/JSON/API) with a schema library","Type inputs as Array<Partial<RequestOptions> | string> strictly"],"tags":["validation","request-queue","type-error"],"backgroundTag":"invalid-input-type","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}