{"record":{"id":"80b9c0193d937ef8","repo":"can1357/oh-my-pi","slug":"javascript-backend-is-disabled-pi-js-0-or-eval-js","errorCode":null,"errorMessage":"JavaScript backend is disabled (PI_JS=0 or eval.js = false).","messagePattern":"JavaScript backend is disabled \\(PI_JS=0 or eval\\.js = false\\)\\.","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/eval.ts","lineNumber":296,"sourceCode":"\t\treturn { backend: rubyBackend };\n\t}\n\tif (language === \"julia\") {\n\t\tif (!allowJl) throw new ToolError(\"Julia backend is disabled (PI_JL=0 or eval.jl = false).\");\n\t\tconst available = await juliaBackend.isAvailable(session, probeOpts);\n\t\tthrowIfAborted(probeOpts?.signal);\n\t\tif (!available) {\n\t\t\tconst alternatives = [allowJs ? '\"js\"' : null, allowPy ? '\"py\"' : null, allowRb ? '\"rb\"' : null].filter(\n\t\t\t\tBoolean,\n\t\t\t);\n\t\t\tthrow new ToolError(\n\t\t\t\talternatives.length > 0\n\t\t\t\t\t? `Julia backend is unavailable in this session. Pass language: ${alternatives.join(\" or \")} or install Julia.`\n\t\t\t\t\t: 'Julia backend is unavailable in this session. Install Julia to use language: \"jl\".',\n\t\t\t);\n\t\t}\n\t\treturn { backend: juliaBackend };\n\t}\n\tif (!allowJs) throw new ToolError(\"JavaScript backend is disabled (PI_JS=0 or eval.js = false).\");\n\treturn { backend: jsBackend };\n}\nfunction formatEvalInputLanguage(value: string): string {\n\tif (value === \"py\" || value === \"python\") return \"python\";\n\tif (value === \"js\" || value === \"javascript\") return \"javascript\";\n\tif (value === \"rb\" || value === \"ruby\") return \"ruby\";\n\tif (value === \"jl\" || value === \"julia\") return \"julia\";\n\treturn value;\n}\n\nexport class EvalTool implements AgentTool<typeof evalSchema> {\n\treadonly name = \"eval\";\n\treadonly approval = \"exec\" as const;\n\treadonly formatApprovalDetails = (args: unknown): string[] => {\n\t\tconst params = args as Partial<EvalToolParams>;\n\t\tconst language =\n\t\t\ttypeof params.language === \"string\" ? formatEvalInputLanguage(params.language) : \"javascript (default)\";\n\t\tconst code = typeof params.code === \"string\" ? params.code : \"\";","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/eval.ts#L278-L314","documentation":"This is the catch-all branch of resolveBackend: JavaScript is the default eval language, and if the JS backend is not allowed (eval.js setting false or PI_JS=0) the resolver refuses. Unlike py/rb/jl, JS has no availability probe here — the Node/Bun runtime is assumed present — so the only way to get this error is explicit disabling via config or env flag.","triggerScenarios":"Calling eval with no language or language \"js\"/\"javascript\" when resolveEvalBackends reports js: false, i.e. the PI_JS environment flag is set to 0 or the eval.js setting is false.","commonSituations":"Hardened/locked-down configurations that disable JS eval for safety; users who set PI_JS=0 expecting only to restrict one language but calling eval without an explicit language; migrated configs where eval.js was turned off.","solutions":["Set eval.js to true in settings (or remove the eval.js=false override) to re-enable the default JS backend.","Remove PI_JS=0 from the environment or set PI_JS=1.","Pass an explicitly enabled language (\"py\", \"rb\", or \"jl\") instead of relying on the JS default."],"exampleFix":"// before\n{ \"code\": \"1+1\" } // defaults to js, which is disabled\n// after\n{ \"language\": \"py\", \"code\": \"1+1\" }\n// or re-enable JS: export PI_JS=1","handlingStrategy":"validation","validationCode":"const backends = resolveEvalBackends(session);\nconst lang = backends.js ? \"js\" : backends.python ? \"py\" : null;\nif (!lang) throw new Error(\"no eval backend enabled\");\n// call eval with explicit language instead of relying on the js default","typeGuard":"function jsEnabled(b: { js: boolean }): b is { js: true } { return b.js; }","tryCatchPattern":"try {\n  await evalTool.execute(id, params, signal);\n} catch (e) {\n  if (e instanceof ToolError && e.message.includes(\"JavaScript backend is disabled\")) {\n    // retry with an explicitly enabled language or surface config guidance\n  } else throw e;\n}","preventionTips":["Never rely on the implicit js default without confirming PI_JS is not 0.","Audit environment flags (PI_JS/PI_PY/PI_RB/PI_JL) when eval calls fail at startup.","Always pass an explicit language resolved from resolveEvalBackends."],"tags":["configuration","eval-tool","javascript","feature-flag"],"backgroundTag":"feature-disabled-by-config","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}