can1357/oh-my-pi · error · Error

No coherent browser profile matches the requested options

Error message

No coherent browser profile matches the requested options

What it means

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.

Source

Thrown at packages/utils/src/headers.ts:103

				? "Macintosh; Intel Mac OS X 10_15_7"
				: "X11; Linux x86_64";
	if (browser === "firefox") {
		return `Mozilla/5.0 (${platform}; rv:${version}.0) Gecko/20100101 Firefox/${version}.0`;
	}
	return `Mozilla/5.0 (${platform}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version}.0.0.0 Safari/537.36`;
}

function makeProfile(options: ResolvedOptions, rng: () => number): BrowserProfile {
	const candidates: Array<{ browser: BrowserName; operatingSystem: OperatingSystem }> = [];
	for (const browser of options.browsers) {
		for (const operatingSystem of options.operatingSystems) {
			if (browser === "safari" && operatingSystem !== "macos") continue;
			candidates.push({ browser, operatingSystem });
		}
	}

	if (candidates.length === 0) {
		if (options.strict) throw new Error("No coherent browser profile matches the requested options");
		candidates.push({ browser: "chrome", operatingSystem: "windows" });
	}

	const candidate = pick(candidates, rng);
	const version = pick(VERSIONS[candidate.browser], rng);
	return {
		...candidate,
		version,
		userAgent: makeUserAgent(candidate.browser, candidate.operatingSystem, version),
	};
}

/** Generates coherent modern desktop browser navigation headers. */
export class HeaderGenerator {
	#options: ResolvedOptions;
	#rng: () => number;

	/** Creates a generator with reusable constraints and an optionally injectable RNG. */

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove strict: true to get the chrome/windows fallback
  2. Include 'macos' in operatingSystems when browsers includes 'safari'
  3. Add a non-safari browser (chrome/firefox) to the browsers list
  4. Validate browser/OS arrays are non-empty before constructing

Example fix

// before
new HeaderGenerator({ strict: true, browsers: ["safari"], operatingSystems: ["windows"] });
// after
new HeaderGenerator({ strict: true, browsers: ["safari"], operatingSystems: ["macos"] });
Defensive patterns

Strategy: validation

Validate before calling

const coherent =
  (options.browsers ?? ["chrome"]).length > 0 &&
  (options.browsers ?? []).every(b => b !== "safari" || (options.operatingSystems ?? []).includes("macos"));
if (options.strict && !coherent) throw new Error("fix browser/OS combination before constructing");

Try / catch

try {
  const gen = new HeaderGenerator({ strict: true, ...opts });
  return gen.getHeaders();
} catch (err) {
  if (err instanceof Error && err.message.includes("No coherent browser profile")) {
    return new HeaderGenerator().getHeaders(); // fall back to defaults (non-strict)
  }
  throw err;
}

Prevention

When it happens

Trigger: new HeaderGenerator({ strict: true, browsers: ['safari'], operatingSystems: ['windows'] }).getHeaders(); or strict: true with browsers: [] / operatingSystems: [] — the cartesian product after filtering is empty.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/bdddafc0e316d24c. Report an issue: GitHub.