{"record":{"id":"bdddafc0e316d24c","repo":"can1357/oh-my-pi","slug":"no-coherent-browser-profile-matches-the-requested","errorCode":null,"errorMessage":"No coherent browser profile matches the requested options","messagePattern":"No coherent browser profile matches the requested options","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/utils/src/headers.ts","lineNumber":103,"sourceCode":"\t\t\t\t? \"Macintosh; Intel Mac OS X 10_15_7\"\n\t\t\t\t: \"X11; Linux x86_64\";\n\tif (browser === \"firefox\") {\n\t\treturn `Mozilla/5.0 (${platform}; rv:${version}.0) Gecko/20100101 Firefox/${version}.0`;\n\t}\n\treturn `Mozilla/5.0 (${platform}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version}.0.0.0 Safari/537.36`;\n}\n\nfunction makeProfile(options: ResolvedOptions, rng: () => number): BrowserProfile {\n\tconst candidates: Array<{ browser: BrowserName; operatingSystem: OperatingSystem }> = [];\n\tfor (const browser of options.browsers) {\n\t\tfor (const operatingSystem of options.operatingSystems) {\n\t\t\tif (browser === \"safari\" && operatingSystem !== \"macos\") continue;\n\t\t\tcandidates.push({ browser, operatingSystem });\n\t\t}\n\t}\n\n\tif (candidates.length === 0) {\n\t\tif (options.strict) throw new Error(\"No coherent browser profile matches the requested options\");\n\t\tcandidates.push({ browser: \"chrome\", operatingSystem: \"windows\" });\n\t}\n\n\tconst candidate = pick(candidates, rng);\n\tconst version = pick(VERSIONS[candidate.browser], rng);\n\treturn {\n\t\t...candidate,\n\t\tversion,\n\t\tuserAgent: makeUserAgent(candidate.browser, candidate.operatingSystem, version),\n\t};\n}\n\n/** Generates coherent modern desktop browser navigation headers. */\nexport class HeaderGenerator {\n\t#options: ResolvedOptions;\n\t#rng: () => number;\n\n\t/** Creates a generator with reusable constraints and an optionally injectable RNG. */","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/headers.ts#L85-L121","documentation":"makeProfile builds browser×OS candidates but skips incoherent pairs (safari only runs on macOS). If strict mode is on and no coherent combination remains (e.g. browsers: ['safari'] with operatingSystems: ['windows','linux'], or an empty browsers list), it throws this Error instead of silently relaxing. In non-strict mode it falls back to chrome/windows.","triggerScenarios":"new HeaderGenerator({ strict: true, browsers: ['safari'], operatingSystems: ['windows'] }).getHeaders(); or strict: true with browsers: [] / operatingSystems: [] — the cartesian product after filtering is empty.","commonSituations":"Porting strict header-generator configs where the browser list is dynamically filtered to safari only; user config pinning safari on a non-macOS spoof target; empty arrays read from settings files.","solutions":["Remove strict: true to get the chrome/windows fallback","Include 'macos' in operatingSystems when browsers includes 'safari'","Add a non-safari browser (chrome/firefox) to the browsers list","Validate browser/OS arrays are non-empty before constructing"],"exampleFix":"// before\nnew HeaderGenerator({ strict: true, browsers: [\"safari\"], operatingSystems: [\"windows\"] });\n// after\nnew HeaderGenerator({ strict: true, browsers: [\"safari\"], operatingSystems: [\"macos\"] });","handlingStrategy":"validation","validationCode":"const coherent =\n  (options.browsers ?? [\"chrome\"]).length > 0 &&\n  (options.browsers ?? []).every(b => b !== \"safari\" || (options.operatingSystems ?? []).includes(\"macos\"));\nif (options.strict && !coherent) throw new Error(\"fix browser/OS combination before constructing\");","typeGuard":null,"tryCatchPattern":"try {\n  const gen = new HeaderGenerator({ strict: true, ...opts });\n  return gen.getHeaders();\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"No coherent browser profile\")) {\n    return new HeaderGenerator().getHeaders(); // fall back to defaults (non-strict)\n  }\n  throw err;\n}","preventionTips":["Pair 'safari' with 'macos' in operatingSystems","Include chrome or firefox as a fallback browser","Only enable strict mode with fully specified, validated option sets","Validate config-derived arrays are non-empty"],"tags":["headers","validation","strict-mode","configuration"],"backgroundTag":"incoherent-header-profile","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}