apify/crawlee · error · Error

Request options are not valid, the 'requestsFromUrl' propert

Error message

Request options are not valid, the 'requestsFromUrl' property is not a string. Input: ${inspect(opts)}

What it means

generateRequests() validates that if a request options object declares requestsFromUrl (remote list sourcing), its value must be a string URL. A non-string value (null, number, object) cannot be used to fetch a remote list, so the library throws with an inspect() dump of the offending input.

Source

Thrown at packages/core/src/storages/request_queue.ts:613

                // Validate the input
                if (typeof opts === 'object' && opts !== null) {
                    if (opts.url !== undefined && typeof opts.url !== 'string') {
                        throw new Error(
                            `Request options are not valid, the 'url' property is not a string. Input: ${inspect(opts)}`,
                        );
                    }

                    if (opts.id !== undefined) {
                        throw new Error(
                            `Request options are not valid, the 'id' property must not be present. Input: ${inspect(opts)}`,
                        );
                    }

                    if (
                        (opts as any).requestsFromUrl !== undefined &&
                        typeof (opts as any).requestsFromUrl !== 'string'
                    ) {
                        throw new Error(
                            `Request options are not valid, the 'requestsFromUrl' property is not a string. Input: ${inspect(opts)}`,
                        );
                    }
                }

                if (opts && typeof opts === 'object' && 'requestsFromUrl' in opts) {
                    // Handle URL lists right away
                    await addRequest(opts, { forefront });
                } else {
                    // Yield valid requests
                    yield typeof opts === 'string' ? { url: opts } : (opts as RequestOptions);
                }
            }
        }

        return drainRequestBatches<RequestOptions>({
            items: generateRequests(),
            batchSize,

View on GitHub (pinned to dbe57fb09c)

Solutions

  1. Only include the requestsFromUrl key when it has a valid string URL, or set it to a string
  2. Coerce config values and validate with typeof before enqueuing
  3. Drop items lacking a valid requestsFromUrl (and url) before calling addRequestsBatched
  4. Validate environment/config variables feeding the field are non-empty strings

Example fix

// before
await queue.addRequestsBatched([{ requestsFromUrl: process.env.LIST_URL }]); // may be undefined
// after
const requests = typeof process.env.LIST_URL === 'string' && process.env.LIST_URL
    ? [{ requestsFromUrl: process.env.LIST_URL }] : [];
await queue.addRequestsBatched(requests);
Defensive patterns

Strategy: validation

Validate before calling

if ('requestsFromUrl' in opts && typeof opts.requestsFromUrl !== 'string') {
  throw new Error(`requestsFromUrl must be a string, got ${typeof opts.requestsFromUrl}`);
}

Type guard

function hasValidRequestsFromUrl(r) {
  return !(r && typeof r === 'object' && 'requestsFromUrl' in r && r.requestsFromUrl !== undefined)
    || typeof r.requestsFromUrl === 'string';
}

Try / catch

try {
  await queue.addRequestsBatched(requests);
} catch (err) {
  if (err.message.includes("'requestsFromUrl' property is not a string")) {
    logger.error(`Bad remote-list option: ${err.message}`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling addRequestsBatched with items like { requestsFromUrl: null } or { requestsFromUrl: someObject }; dynamically building options where the remote URL variable is undefined/null or the wrong type; JSON config where the field is empty.

Common situations: Config-driven crawls where the list URL env var is unset and passed straight through; template objects pre-created with requestsFromUrl key but filled later; CSV/API data supplying numeric or nested values for the field.

Related errors


AI-assisted analysis of apify/crawlee@dbe57fb09c (2026-08-30). Data as JSON: /api/errors/a5d4463b00e566a4. Report an issue: GitHub.