{"record":{"id":"4c54b3b2b794b74c","repo":"different-ai/openwork","slug":"server-name-is-required","errorCode":null,"errorMessage":"server_name is required","messagePattern":"server_name is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/electron/runtime.mjs","lineNumber":2269,"sourceCode":"      env: { ...(await buildChildEnv()), OPENCODE_INSTALL_DIR: installDir },\n      timeoutMs: 180_000,\n    });\n    return {\n      ok: result.status === 0,\n      status: result.status,\n      stdout: result.stdout,\n      stderr: result.stderr,\n    };\n  }\n\n  async function opencodeMcpAuth(projectDir, serverName) {\n    const safeProjectDir = String(projectDir ?? \"\").trim();\n    const safeServerName = String(serverName ?? \"\").trim();\n    if (!safeProjectDir) {\n      throw new Error(\"project_dir is required\");\n    }\n    if (!safeServerName) {\n      throw new Error(\"server_name is required\");\n    }\n\n    const program = resolveBinary(\"opencode\");\n    if (!program) {\n      throw new Error(\"Failed to locate opencode.\");\n    }\n\n    const result = await runShellCommand(program, [\"mcp\", \"auth\", safeServerName], {\n      cwd: safeProjectDir,\n      env: await buildChildEnv(),\n      timeoutMs: 120_000,\n    });\n    return {\n      ok: result.status === 0,\n      status: result.status,\n      stdout: result.stdout,\n      stderr: result.stderr,\n    };","sourceCodeStart":2251,"sourceCodeEnd":2287,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/runtime.mjs#L2251-L2287","documentation":"Thrown by `opencodeMcpAuth` in the Electron runtime when the `serverName` argument is missing, null, or whitespace-only. The server name identifies which MCP server to authenticate with via the `opencode` CLI, so it is validated (trimmed, non-empty) before the binary is resolved and executed.","triggerScenarios":"Calling `opencodeMcpAuth(projectDir)`, `opencodeMcpAuth(projectDir, undefined)`, `opencodeMcpAuth(projectDir, null)` or `opencodeMcpAuth(projectDir, \" \")`.","commonSituations":"Renderer sends an MCP auth request for a server entry that was deleted or never had a name; a list-selection bug passing an empty identifier; deserialized config where serverName defaulted to an empty string.","solutions":["Pass the actual MCP server name (non-empty string) to opencodeMcpAuth","Validate/trim serverName at the call site and surface a UI message if it is blank","Fix the data source so server entries always carry a name"],"exampleFix":"// before\nawait opencodeMcpAuth(projectDir, selectedServer?.name);\n// after\nconst name = selectedServer?.name?.trim();\nif (!name) throw new Error('Select an MCP server first');\nawait opencodeMcpAuth(projectDir, name);","handlingStrategy":"validation","validationCode":"function hasServerName(name) {\n  return typeof name === 'string' && name.trim().length > 0;\n}","typeGuard":"function isNamedServer(s) {\n  return typeof s?.name === 'string' && s.name.trim().length > 0;\n}","tryCatchPattern":"try {\n  await opencodeMcpAuth(projectDir, serverName);\n} catch (e) {\n  if (e.message === 'server_name is required') {\n    showError('Select an MCP server to authenticate');\n  } else throw e;\n}","preventionTips":["Validate server entries (name present) when loading MCP config","Disable per-server auth buttons when the entry lacks a name","Trim and check identifiers coming from renderer IPC"],"tags":["argument-validation","electron","mcp"],"backgroundTag":"missing-required-argument","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}