{"record":{"id":"ad5aeabda0fb4d27","repo":"multica-ai/multica","slug":"invalid-desktop-runtime-config-field-must-use","errorCode":null,"errorMessage":"Invalid desktop runtime config: ${field} must use http or https","messagePattern":"Invalid desktop runtime config: (.+?) must use http or https","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/src/shared/runtime-config.ts","lineNumber":150,"sourceCode":"}\n\nfunction optionalString(value: unknown, field: string): string | undefined {\n  if (value === undefined) return undefined;\n  if (typeof value !== \"string\" || value.trim().length === 0) {\n    throw new Error(`Invalid desktop runtime config: ${field} must be a non-empty string when set`);\n  }\n  return value;\n}\n\nfunction normalizeHttpUrl(value: string, field: string): string {\n  let url: URL;\n  try {\n    url = new URL(value.trim());\n  } catch {\n    throw new Error(`Invalid desktop runtime config: ${field} must be a valid URL`);\n  }\n  if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n    throw new Error(`Invalid desktop runtime config: ${field} must use http or https`);\n  }\n  url.search = \"\";\n  url.hash = \"\";\n  return trimTrailingSlash(url.toString());\n}\n\nfunction normalizeWsUrl(value: string, field: string): string {\n  let url: URL;\n  try {\n    url = new URL(value.trim());\n  } catch {\n    throw new Error(`Invalid desktop runtime config: ${field} must be a valid URL`);\n  }\n  if (url.protocol !== \"ws:\" && url.protocol !== \"wss:\") {\n    throw new Error(`Invalid desktop runtime config: ${field} must use ws or wss`);\n  }\n  url.search = \"\";\n  url.hash = \"\";","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/apps/desktop/src/shared/runtime-config.ts#L132-L168","documentation":"Validation error from hermesProfileDir: a profile name that is empty after TrimSpace. It reproduces the Hermes CLI's normalize_profile_name + validate_profile_name contract — Hermes itself sys.exit(1)s on an empty name, so the daemon rejects it before any filesystem work. The returned home/mustExist values are zero.","triggerScenarios":"hermesProfileDir is called with a name that is empty or whitespace-only (strings.TrimSpace(name) == \"\") — e.g. an agent's hermes profile config holds an empty string or only spaces, or a caller trims a variable to nothing before passing it.","commonSituations":"Agent created with HERMES_PROFILE unset/blank in config; a UI form allowing whitespace-only profile names; env var interpolation yielding an empty string; trimming done twice with the second trim producing \"\".","solutions":["Set a real profile name (or \"default\") in the agent's hermes configuration.","Add form/env validation rejecting empty or whitespace-only profile names where they are entered.","If the empty value comes from templating, fix the template default."],"exampleFix":"// before\nprofile := strings.TrimSpace(os.Getenv(\"HERMES_PROFILE\")) // \"\" when unset\nhome, mustExist, err := hermesProfileDir(root, profile) // err: name cannot be empty\n\n// after\nprofile := strings.TrimSpace(os.Getenv(\"HERMES_PROFILE\"))\nif profile == \"\" {\n    profile = \"default\"\n}\nhome, mustExist, err := hermesProfileDir(root, profile)","handlingStrategy":"validation","validationCode":"name := strings.TrimSpace(name)\nif name == \"\" {\n    return fmt.Errorf(\"profile name required\")\n}","typeGuard":"func isValidHermesProfileInput(name string) bool {\n    return strings.TrimSpace(name) != \"\"\n}","tryCatchPattern":"home, mustExist, err := hermesProfileDir(root, name)\nif err != nil {\n    if strings.Contains(err.Error(), \"cannot be empty\") {\n        // fall back to \"default\" or reject at the form/API layer\n    }\n}","preventionTips":["Reject empty/whitespace profile names at data-entry (forms, env parsing).","Default blank HERMES_PROFILE values to \"default\" before calling the daemon.","Unit-test profile resolution with empty/whitespace inputs."],"tags":["go","hermes","validation","profile","execenv"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}