{"record":{"id":"fc88630850e7bcba","repo":"can1357/oh-my-pi","slug":"only-desktop-browser-profiles-are-available","errorCode":null,"errorMessage":"Only desktop browser profiles are available","messagePattern":"Only desktop browser profiles are available","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/utils/src/headers.ts","lineNumber":126,"sourceCode":"\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. */\n\tconstructor(options: Partial<HeaderGeneratorOptions> = {}) {\n\t\tthis.#rng = options.rng ?? Math.random;\n\t\tthis.#options = { ...DEFAULT_OPTIONS, ...options };\n\t\tif (this.#options.devices.some(device => device !== \"desktop\") && this.#options.strict) {\n\t\t\tthrow new Error(\"Only desktop browser profiles are available\");\n\t\t}\n\t\tif (this.#options.locales.length === 0 && this.#options.strict) {\n\t\t\tthrow new Error(\"At least one locale is required\");\n\t\t}\n\t}\n\n\t/** Generates one header set, applying per-call constraints and request overrides. */\n\tgetHeaders(options: Partial<HeaderGeneratorOptions> = {}, overrides: Headers = {}): Headers {\n\t\tconst resolved = { ...this.#options, ...options };\n\t\tconst rng = options.rng ?? this.#rng;\n\t\tconst profile = makeProfile(resolved, rng);\n\t\tconst headers: Headers = {\n\t\t\taccept:\n\t\t\t\tprofile.browser === \"chrome\"\n\t\t\t\t\t? \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\"\n\t\t\t\t\t: \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n\t\t\t\"user-agent\": profile.userAgent,\n\t\t\t\"accept-encoding\": profile.browser === \"safari\" ? \"gzip, deflate, br\" : \"gzip, deflate, br, zstd\",","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/headers.ts#L108-L144","documentation":"HeaderGenerator only implements desktop browser profiles, so its devices option only accepts 'desktop'. If strict mode is enabled and the (merged) options contain any non-desktop device — e.g. 'mobile' or 'tablet', perhaps from configs written against the original header-generator package — the constructor throws this Error immediately.","triggerScenarios":"new HeaderGenerator({ strict: true, devices: ['mobile'] }) or passing a devices array read from older header-generator config containing 'mobile'/'tablet'. Note DEFAULT_OPTIONS merge means a per-call getHeaders({ devices: [...] }) with strict also flows into makeProfile path, but the constructor check fires on constructor options.","commonSituations":"Migrating from apify/header-generator whose options include mobile/tablet device classes; config files copied from other projects with devices: ['desktop','mobile'].","solutions":["Remove non-desktop values from the devices array","Set strict: false to tolerate the extra device values (they are then ignored)","Drop the devices option entirely (desktop is the default)"],"exampleFix":"// before\nnew HeaderGenerator({ strict: true, devices: [\"desktop\", \"mobile\"] });\n// after\nnew HeaderGenerator({ strict: true, devices: [\"desktop\"] });","handlingStrategy":"validation","validationCode":"const devices = options.devices ?? [\"desktop\"];\nif (options.strict && devices.some(d => d !== \"desktop\")) {\n  throw new Error(\"this generator supports desktop devices only\");\n}","typeGuard":"function isDesktopOnly(devices: readonly string[]): boolean {\n  return devices.every(d => d === \"desktop\");\n}","tryCatchPattern":"try {\n  return new HeaderGenerator(opts);\n} catch (err) {\n  if (err instanceof Error && err.message === \"Only desktop browser profiles are available\") {\n    return new HeaderGenerator({ ...opts, devices: [\"desktop\"] });\n  }\n  throw err;\n}","preventionTips":["Strip 'mobile'/'tablet' when migrating configs from header-generator","Remember this library supports desktop profiles only","Sanitize devices arrays read from user config","Leave strict off if legacy option sets must be tolerated"],"tags":["headers","validation","strict-mode","migration"],"backgroundTag":"unsupported-option-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}