{"record":{"id":"ed0f423b751a5565","repo":"diegosouzapw/OmniRoute","slug":"system-proxy-apply-failed","errorCode":null,"errorMessage":"system proxy apply failed","messagePattern":"system proxy apply failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mitm/inspector/systemProxyConfig.ts","lineNumber":275,"sourceCode":"// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Apply OmniRoute as the system-wide HTTP/HTTPS proxy at `127.0.0.1:<port>`.\n * Captures and returns the prior configuration so callers can revert later.\n *\n * Throws a sanitized `Error` if the underlying command fails (no stack/path\n * leakage — see Hard Rule #12).\n */\nexport async function apply(port: number): Promise<ApplyResult> {\n  const platform = detectPlatform();\n  try {\n    let previousState: PreviousState;\n    if (platform === \"macos\") previousState = await macosApply(port);\n    else if (platform === \"windows\") previousState = await windowsApply(port);\n    else previousState = await linuxApply(port);\n    return { platform, previousState };\n  } catch (err) {\n    throw new Error(sanitizeErrorMessage(err) || \"system proxy apply failed\");\n  }\n}\n\n/**\n * Restore the prior configuration captured by `apply()`. No-op if the\n * `previousState` payload does not match a known platform.\n */\nexport async function revert(previousState: PreviousState | unknown): Promise<void> {\n  if (!previousState || typeof previousState !== \"object\") return;\n  const state = previousState as Record<string, unknown>;\n  const platform = state.platform;\n  try {\n    if (platform === \"macos\") await macosRevert(state as unknown as MacOsPreviousState);\n    else if (platform === \"linux\") await linuxRevert(state as unknown as LinuxPreviousState);\n    else if (platform === \"windows\") await windowsRevert(state as unknown as WindowsPreviousState);\n  } catch (err) {\n    throw new Error(sanitizeErrorMessage(err) || \"system proxy revert failed\");\n  }","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/mitm/inspector/systemProxyConfig.ts#L257-L293","documentation":"Sanitized catch-all from apply(): the platform-specific system-proxy mutation (macosApply/linux/windows) threw, and the raw error was collapsed via sanitizeErrorMessage — or, when sanitization produced nothing, this literal fallback text. Means the OS-level proxy setting did NOT change (prior state is not reliable); the true cause (command failure, permissions) is intentionally not leaked per Hard Rule #12.","triggerScenarios":"Thrown at src/mitm/inspector/systemProxyConfig.ts:275 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run apply() and watch system logs to identify the failing OS command","Verify sudo/admin privileges for changing system proxy settings","Prefer revert() with the captured previousState only if the platform reported partial success"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}