{"record":{"id":"2be3eb2964725019","repo":"can1357/oh-my-pi","slug":"host-uri-scheme-contains-invalid-characters-raw","errorCode":null,"errorMessage":"Host URI scheme contains invalid characters: ${raw.scheme}","messagePattern":"Host URI scheme contains invalid characters: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/rpc/host-uris.ts","lineNumber":98,"sourceCode":"\n\tgetSchemes(): string[] {\n\t\treturn Array.from(this.#definitions.keys());\n\t}\n\n\t/**\n\t * Replace the registered set of host URI schemes. Previously registered\n\t * schemes that no longer appear in the new set are unregistered from the\n\t * router; surviving and new schemes get fresh handler instances.\n\t */\n\tsetSchemes(schemes: RpcHostUriSchemeDefinition[]): string[] {\n\t\tconst normalized = new Map<string, RpcHostUriSchemeDefinition>();\n\t\tfor (const raw of schemes) {\n\t\t\tconst scheme = typeof raw?.scheme === \"string\" ? raw.scheme.trim().toLowerCase() : \"\";\n\t\t\tif (!scheme) {\n\t\t\t\tthrow new Error(\"Host URI scheme must be a non-empty string\");\n\t\t\t}\n\t\t\tif (!/^[a-z][a-z0-9+.-]*$/.test(scheme)) {\n\t\t\t\tthrow new Error(`Host URI scheme contains invalid characters: ${raw.scheme}`);\n\t\t\t}\n\t\t\tif (RESERVED_HOST_URI_SCHEMES.has(scheme)) {\n\t\t\t\tthrow new Error(`Host URI scheme is reserved by OMP: ${scheme}://`);\n\t\t\t}\n\t\t\tnormalized.set(scheme, {\n\t\t\t\tscheme,\n\t\t\t\tdescription: typeof raw.description === \"string\" ? raw.description : undefined,\n\t\t\t\twritable: raw.writable === true,\n\t\t\t\timmutable: raw.immutable === true,\n\t\t\t});\n\t\t}\n\n\t\tfor (const previous of this.#definitions.keys()) {\n\t\t\tif (!normalized.has(previous)) {\n\t\t\t\tthis.#router.unregister(previous);\n\t\t\t}\n\t\t}\n\t\tfor (const definition of normalized.values()) {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/rpc/host-uris.ts#L80-L116","documentation":"setSchemes enforces the URI scheme grammar /^[a-z][a-z0-9+.-]*$/ (after trim+lowercase). A scheme that starts with a digit, contains underscores, spaces, or other illegal characters is rejected with this error so host URIs remain parseable.","triggerScenarios":"Calling setSchemes with a scheme like \"my_scheme\", \"1ftp\", \"my host\", or any value that fails the scheme regex — even if it is a non-empty string.","commonSituations":"Users writing snake_case scheme names in config; copy-pasted schemes with spaces or uppercase+symbols; schemes generated from file names that contain invalid characters.","solutions":["Rename the scheme to match [a-z][a-z0-9+.-]* — letters/digits/plus/dot/hyphen, starting with a letter (e.g. my-scheme)","Normalize identifiers before registration: lowercase and replace invalid chars (underscore → hyphen)","Validate schemes with the regex client-side before calling setSchemes to give a friendlier error"],"exampleFix":"// before\nsetSchemes([{ scheme: \"my_scheme\" }]);\n// after\nconst scheme = rawIdentifier.toLowerCase().replace(/[^a-z0-9+.-]/g, \"-\").replace(/^[^a-z]/, \"a$&\");\nsetSchemes([{ scheme }]);","handlingStrategy":"validation","validationCode":"const SCHEME_RE = /^[a-z][a-z0-9+.-]*$/;\nif (!SCHEME_RE.test(scheme.trim().toLowerCase())) throw new Error(`Invalid scheme: ${scheme}`);","typeGuard":"function isWellFormedScheme(s: string): boolean {\n  return /^[a-z][a-z0-9+.-]*$/.test(s.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  hostUris.setSchemes(defs);\n} catch (err) {\n  if (err.message.startsWith(\"Host URI scheme contains invalid characters\")) {\n    logger.warn(\"Fixing scheme names and retrying\", { raw: defs.map(d => d.scheme) });\n    hostUris.setSchemes(defs.map(sanitizeScheme));\n  } else throw err;\n}","preventionTips":["Normalize identifiers to lowercase and replace invalid chars before registering","Use hyphens, never underscores or spaces, in scheme names","Start scheme names with a letter","Validate against the scheme regex in config validation"],"tags":["validation","rpc","host-uri","naming"],"backgroundTag":"invalid-uri-scheme","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}