{"record":{"id":"c598ec512af879cf","repo":"apify/crawlee","slug":"cannot-combine-custom-proxies-options-proxyurls","errorCode":null,"errorMessage":"Cannot combine custom proxies \"options.proxyUrls\" with custom generating function \"options.newUrlFunction\".","messagePattern":"Cannot combine custom proxies \"options\\.proxyUrls\" with custom generating function \"options\\.newUrlFunction\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/proxy_configuration.ts","lineNumber":196,"sourceCode":"    /**\n     * Calls the custom newUrlFunction and checks format of its return value\n     */\n    private async callNewUrlFunction(options?: { request?: Request }) {\n        const proxyUrl = await this.#newUrlFunction!(options);\n        try {\n            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":178,"sourceCodeEnd":205,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/proxy_configuration.ts#L178-L205","documentation":"ProxyConfiguration supports either a static list of proxyUrls or a dynamic newUrlFunction, but not both at once — the two custom-supply mechanisms are mutually exclusive. throwCannotCombineCustomMethods is invoked from the constructor when both options are present.","triggerScenarios":"Calling new ProxyConfiguration({ proxyUrls: [...], newUrlFunction: fn }) — both keys present in the options object (including via a spread config that happens to include both).","commonSituations":"Merging default config with user config where both define proxy strategies; refactoring from proxyUrls to newUrlFunction and leaving the old key; copy-pasting two example snippets together.","solutions":["Remove proxyUrls if dynamic generation is needed, keeping only newUrlFunction.","Remove newUrlFunction and keep the static proxyUrls list if static behavior is intended.","Move the static list inside newUrlFunction logic if you need a hybrid (rotate from a fixed list).","Log/inspect the merged options object to find where the extra key comes from."],"exampleFix":"// before\nconst proxy = new ProxyConfiguration({ proxyUrls: ['http://p:8000'], newUrlFunction: () => pick() });\n// after\nconst proxy = new ProxyConfiguration({ newUrlFunction: () => pick() });","handlingStrategy":"validation","validationCode":"if (opts.proxyUrls && opts.newUrlFunction) {\n  throw new Error('Provide either proxyUrls or newUrlFunction, not both');\n}","typeGuard":null,"tryCatchPattern":"try {\n  proxy = new ProxyConfiguration(mergedOpts);\n} catch (err) {\n  if ((err as Error).message.includes('Cannot combine custom proxies')) {\n    const { proxyUrls, ...rest } = mergedOpts;\n    proxy = new ProxyConfiguration(rest); // prefer newUrlFunction\n  } else throw err;\n}","preventionTips":["Pick one proxy supply mechanism per configuration.","When merging configs, delete proxyUrls if newUrlFunction is present (or vice versa).","Keep proxy config in a single typed factory.","Note the constructor is where the conflict is detected — validate before spreading user options."],"tags":["proxy","configuration","conflicting-options"],"backgroundTag":"conflicting-options","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}