{"record":{"id":"b0e133bcf5723fa9","repo":"can1357/oh-my-pi","slug":"host-uri-scheme-must-be-a-non-empty-string","errorCode":null,"errorMessage":"Host URI scheme must be a non-empty string","messagePattern":"Host URI scheme must be a non-empty string","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/rpc/host-uris.ts","lineNumber":95,"sourceCode":"\t\tthis.#output = output;\n\t\tthis.#router = router;\n\t}\n\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);","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/rpc/host-uris.ts#L77-L113","documentation":"RpcHostUriSchemes.setSchemes validates each registered host URI scheme definition and throws when the scheme field is missing, not a string, or empty/whitespace after trimming/lowercasing. Schemes are the foundation of host:// URIs, so an unusable scheme name is rejected up front.","triggerScenarios":"Calling setSchemes with an entry whose .scheme is undefined/null/non-string, or an empty string or only whitespace (e.g. { scheme: \"\", description: ... }).","commonSituations":"Config file with a scheme entry missing the key or set to \"\"; programmatic registration passing a malformed object; deserialized JSON where the scheme field was dropped.","solutions":["Provide a non-empty scheme string on every entry passed to setSchemes","Trim user input and reject empty values before calling setSchemes","Fix the config/source supplying the definitions (missing or blank scheme key)","Validate entries against RpcHostUriSchemeDefinition (scheme: required string) before registration"],"exampleFix":"// before\nsetSchemes([{ scheme: \"\", description: \"docs\" }]);\n// after\nsetSchemes([{ scheme: \"docs\", description: \"docs\" }]);","handlingStrategy":"validation","validationCode":"function isValidSchemeEntry(raw) {\n  return typeof raw?.scheme === \"string\" && raw.scheme.trim().length > 0;\n}\nsetSchemes(defs.filter(isValidSchemeEntry));","typeGuard":"function hasScheme(raw: unknown): raw is { scheme: string } {\n  return typeof (raw as { scheme?: unknown })?.scheme === \"string\" && (raw as { scheme: string }).scheme.trim() !== \"\";\n}","tryCatchPattern":"try {\n  hostUris.setSchemes(defs);\n} catch (err) {\n  if (err.message === \"Host URI scheme must be a non-empty string\") {\n    logger.warn(\"Dropping scheme entries with empty/missing scheme\", { count: defs.length });\n  } else throw err;\n}","preventionTips":["Always require and trim the scheme field in config parsing","Reject blank scheme entries at config-load time with a clear message","Type definitions so scheme is a required non-empty string","Add a unit test covering missing/blank scheme input"],"tags":["validation","rpc","host-uri","config"],"backgroundTag":"invalid-uri-scheme","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}