{"record":{"id":"3383b62f863da841","repo":"apify/crawlee","slug":"one-of-options-proxyurls-or-options-newurlfunct","errorCode":null,"errorMessage":"One of \"options.proxyUrls\" or \"options.newUrlFunction\" needs to be provided.","messagePattern":"One of \"options\\.proxyUrls\" or \"options\\.newUrlFunction\" needs to be provided\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/proxy_configuration.ts","lineNumber":202,"sourceCode":"            if (proxyUrl) {\n                new URL(proxyUrl); // eslint-disable-line no-new\n            }\n            return proxyUrl;\n        } catch (err) {\n            throw new Error(\n                `The provided newUrlFunction did not return a valid URL.\\nCause: ${(err as Error).message}`,\n            );\n        }\n    }\n\n    private throwCannotCombineCustomMethods(): never {\n        throw new Error(\n            'Cannot combine custom proxies \"options.proxyUrls\" with custom generating function \"options.newUrlFunction\".',\n        );\n    }\n\n    private throwNoOptionsProvided(): never {\n        throw new Error('One of \"options.proxyUrls\" or \"options.newUrlFunction\" needs to be provided.');\n    }\n}\n","sourceCodeStart":184,"sourceCodeEnd":205,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/proxy_configuration.ts#L184-L205","documentation":"A ProxyConfiguration must be given at least one proxy source: a static proxyUrls array or a dynamic newUrlFunction. If neither is provided (and validateRequired isn't bypassing), the constructor throws this error because the configuration would have no proxies to hand out.","triggerScenarios":"Calling new ProxyConfiguration() with an empty object, or with an options object from which both proxyUrls and newUrlFunction are absent/undefined (e.g. empty env-derived config).","commonSituations":"Environment variables for proxies unset so parsed options end up empty; spreading an empty/partial config; forgetting to pass options when switching from a constructor that required them.","solutions":["Provide proxyUrls: new ProxyConfiguration({ proxyUrls: ['http://proxy:8000'] }).","Or provide newUrlFunction returning a proxy URL dynamically.","Check that the env vars/config feeding the options are actually set before constructing.","If proxies are genuinely optional, conditionally construct ProxyConfiguration only when options exist."],"exampleFix":"// before\nconst proxy = new ProxyConfiguration({}); // throws\n// after\nconst opts = process.env.PROXY_URLS ? { proxyUrls: process.env.PROXY_URLS.split(',') } : undefined;\nconst proxy = opts ? new ProxyConfiguration(opts) : undefined;","handlingStrategy":"validation","validationCode":"const hasProxySource = Boolean(opts?.proxyUrls?.length || opts?.newUrlFunction);\nif (!hasProxySource) {\n  throw new Error('ProxyConfiguration requires proxyUrls or newUrlFunction');\n}","typeGuard":"function hasProxyOptions(o: unknown): o is { proxyUrls?: string[]; newUrlFunction?: () => string } {\n  const v = o as any;\n  return v && (Array.isArray(v.proxyUrls) && v.proxyUrls.length > 0 || typeof v.newUrlFunction === 'function');\n}","tryCatchPattern":"try {\n  proxy = new ProxyConfiguration(opts);\n} catch (err) {\n  if ((err as Error).message.includes('needs to be provided')) {\n    console.warn('No proxy configured; running without proxy');\n    proxy = undefined;\n  } else throw err;\n}","preventionTips":["Verify proxy env vars are set before constructing the configuration.","Make ProxyConfiguration optional in code that runs with or without proxies.","Validate config objects at startup, not deep in the run.","Avoid spreading partially-filled option objects into the constructor."],"tags":["proxy","configuration","missing-argument"],"backgroundTag":"missing-required-option","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}