{"record":{"id":"c239fb19734ef4a9","repo":"siyuan-note/siyuan","slug":"remote-requires-a-url","errorCode":null,"errorMessage":"--remote requires a URL","messagePattern":"--remote requires a URL","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/electron/remoteKernel.js","lineNumber":15,"sourceCode":"const crypto = require(\"node:crypto\");\n\n// 解析命令行参数时保留值中的等号，避免 URL 查询参数被截断。\nconst getArgFrom = (args, name) => {\n    const prefix = name + \"=\";\n    const arg = args.find((item) => item === name || item.startsWith(prefix));\n    if (!arg) {\n        return;\n    }\n    return arg === name ? \"\" : arg.slice(prefix.length);\n};\n\nconst normalizeRemoteKernelOrigin = (value) => {\n    if (!value) {\n        throw new Error(\"--remote requires a URL\");\n    }\n    const url = new URL(value);\n    if (url.username || url.password) {\n        throw new Error(\"--remote does not accept credentials in the URL\");\n    }\n    if (url.pathname !== \"/\" || url.search || url.hash || value.includes(\"?\") || value.includes(\"#\")) {\n        throw new Error(\"--remote only accepts an origin without a path, query, or fragment\");\n    }\n    if (url.protocol !== \"https:\") {\n        throw new Error(\"--remote requires HTTPS\");\n    }\n    return url.origin;\n};\n\nconst insecureCertificateSwitchNames = Object.freeze([\n    \"allow-insecure-localhost\",\n    \"ignore-certificate-errors\",\n    \"ignore-certificate-errors-spki-list\",","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/electron/remoteKernel.js#L1-L33","documentation":"normalizeRemoteKernelOrigin parses the value passed to the --remote CLI switch. It throws this when the switch is present but its value is empty/missing, because a remote kernel connection cannot proceed without a URL.","triggerScenarios":"Launching the Electron app with --remote and no argument, or --remote= with an empty value; the preceding argument-parsing helper returns \"\" when the arg is exactly the switch name.","commonSituations":"Copy-pasting a shortcut/desktop launcher where the URL after --remote was lost; shell quoting issues swallowing the URL; forgetting the value entirely when editing the command line.","solutions":["Pass the full origin URL: --remote https://host:port","Check your shortcut/launcher config — ensure the URL survived as a separate argument after --remote","Quote the URL if your shell treats characters like ? or # specially","Omit --remote entirely to start in local mode"],"exampleFix":"// before\n//   SiYuan --remote\n// after\n//   SiYuan --remote \"https://myhost:6806\"","handlingStrategy":"validation","validationCode":"// In your launcher script, fail fast before spawning Electron:\n// [ -n \"$REMOTE_URL\" ] || { echo \"REMOTE_URL required\"; exit 1; }\n// exec siyuan --remote \"$REMOTE_URL\"","typeGuard":null,"tryCatchPattern":"try {\n  const origin = normalizeRemoteKernelOrigin(args.remote);\n} catch (e) {\n  if (e.message === \"--remote requires a URL\") {\n    // print usage: --remote https://host:port\n  }\n}","preventionTips":["Always pass the URL immediately after --remote in launchers and scripts","Quote the URL to survive shell parsing","Validate your desktop shortcut command line after editing it"],"tags":["cli","argument-validation","remote-kernel","missing-value"],"backgroundTag":"missing-required-argument","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}