{"record":{"id":"1f55cbb1d960a475","repo":"can1357/oh-my-pi","slug":"missing-required-parameter-code-for-action-run","errorCode":null,"errorMessage":"Missing required parameter 'code' for action 'run'.","messagePattern":"Missing required parameter 'code' for action 'run'\\.","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/browser.ts","lineNumber":388,"sourceCode":"\t\tif (params.all) {\n\t\t\tconst count = await untilAborted(signal, () => releaseAllTabs({ kill, timeoutMs }));\n\t\t\tdetails.result = `Released ${count} managed tab${count === 1 ? \"\" : \"s\"}`;\n\t\t\treturn toolResult(details).text(details.result).done();\n\t\t}\n\t\tconst closed = await untilAborted(signal, () => releaseTab(name, { kill, timeoutMs }));\n\t\tdetails.result = closed ? `Released managed tab ${JSON.stringify(name)}` : `No tab named ${JSON.stringify(name)}`;\n\t\treturn toolResult(details).text(details.result).done();\n\t}\n\n\tasync #run(\n\t\tname: string,\n\t\tparams: BrowserParams,\n\t\tdetails: BrowserToolDetails,\n\t\ttimeoutMs: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<AgentToolResult<BrowserToolDetails>> {\n\t\tif (!params.code?.trim()) {\n\t\t\tthrow new ToolError(\"Missing required parameter 'code' for action 'run'.\");\n\t\t}\n\t\tconst tab = getTab(name);\n\t\tif (tab) {\n\t\t\tdetails.browser = tab.browser.kind.kind;\n\t\t\tdetails.url = tab.info.url;\n\t\t}\n\n\t\tconst { displays, returnValue, screenshots } = await runInTab(name, {\n\t\t\tcode: params.code,\n\t\t\ttimeoutMs,\n\t\t\tsignal,\n\t\t\tsession: this.session,\n\t\t});\n\n\t\tif (screenshots.length) details.screenshots = screenshots;\n\n\t\tconst content = [...displays];\n\t\tif (returnValue !== undefined) {","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/browser.ts#L370-L406","documentation":"Action 'run' executes user-supplied JavaScript in the tab; params.code is mandatory. When code is missing, empty, or whitespace-only, this ToolError is thrown before any tab lookup. It is a required-parameter validation error.","triggerScenarios":"Calling browser run with action:'run' but no code field; code set to '' or only whitespace after a templating mistake; model-generated args omitting code while emitting other fields.","commonSituations":"Prompt/template bug dropping the code argument; copying an 'open'/'close' payload and switching action to 'run' without adding code; SDK wrapper not forwarding the code field.","solutions":["Provide a non-empty code string with the run action","Check the caller/template that builds the params object to ensure code is included","Validate params before sending (action==='run' requires trimmed-nonempty code)","Use the correct action if you did not intend to execute code"],"exampleFix":"// before\nawait browser.run({ action: 'run' })\n// after\nawait browser.run({ action: 'run', code: 'document.title' })","handlingStrategy":"validation","validationCode":"if (params.action === 'run' && typeof params.code !== 'string') {\n\tthrow new Error(\"action 'run' requires a non-empty 'code' string\");\n}","typeGuard":"function hasRunCode(p: { action: string; code?: string }): p is { action: 'run'; code: string } {\n\treturn p.action !== 'run' || (typeof p.code === 'string' && p.code.trim().length > 0);\n}","tryCatchPattern":"try {\n\tawait browser.run({ action: 'run', code });\n} catch (err) {\n\tif (err instanceof ToolError && /Missing required parameter 'code'/.test(err.message)) {\n\t\t// fix params generation, then retry with code supplied\n\t} else throw err;\n}","preventionTips":["Always include code when action is 'run'","Trim-check the code argument in wrappers before dispatch","Use strict JSON schemas so the model must emit code","Avoid swapping action values without updating the payload fields"],"tags":["validation","missing-parameter","browser"],"backgroundTag":"missing-required-parameter","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}