{"record":{"id":"7c9b158dbe205bd7","repo":"theonedev/onedev","slug":"unrecognized-interpolation-variable-t-7c9b15","errorCode":null,"errorMessage":"Unrecognized interpolation variable: ${t}","messagePattern":"Unrecognized interpolation variable: (.+?)","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/interpolative/WorkspaceVariableInterpolator.java","lineNumber":43,"sourceCode":"\t\t\t\t\treturn value != null ? value : \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (t.startsWith(PREFIX_SCRIPT) || t.startsWith(\"scripts:\")) {\n\t\t\t\tString scriptName;\n\t\t\t\tif (t.startsWith(PREFIX_SCRIPT))\n\t\t\t\t\tscriptName = t.substring(PREFIX_SCRIPT.length());\n\t\t\t\telse\n\t\t\t\t\tscriptName = t.substring(\"scripts:\".length());\n\n\t\t\t\tMap<String, Object> context = new HashMap<>();\n\t\t\t\tcontext.put(\"workspace\", workspace);\n\t\t\t\tObject result = GroovyUtils.evalScriptByName(scriptName, context);\n\t\t\t\tif (result != null)\n\t\t\t\t\treturn result.toString();\n\t\t\t\telse\n\t\t\t\t\treturn \"\";\n\t\t\t} else {\n\t\t\t\tthrow new ExplicitException(\"Unrecognized interpolation variable: \" + t);\n\t\t\t}\n\t\t});\n\t}\n\t\n\tpublic WorkspaceVariableInterpolator(Function<String, String> variableResolver) {\n\t\tthis.variableResolver = variableResolver;\n\t}\n\n\t@Override\n\tprotected Function<String, String> getVariableResolver() {\n\t\treturn variableResolver;\n\t}\n\n\tpublic static String getHelp() {\n\t\treturn _T(\"<b>Tips: </b> Type <tt>@</tt> to <a href='https://docs.onedev.io/appendix/workspace-variables' target='_blank' tabindex='-1'>insert variable</a>. \"\n\t\t\t+ \"Use <tt>@@</tt> for literal <tt>@</tt>\");\n\t}\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/interpolative/WorkspaceVariableInterpolator.java#L25-L61","documentation":"WorkspaceVariableInterpolator resolves @...@ tokens in workspace (build context) expressions, supporting built-ins plus script-name variables evaluated via GroovyUtils.evalScriptByName. When a token matches none of the recognized forms, it throws ExplicitException 'Unrecognized interpolation variable'. Like its job counterpart, it is a strict fallback for unknown variable syntax.","triggerScenarios":"A workspace expression contains '@token@' where 'token' is neither a built-in workspace variable nor the name of a Groovy script resolvable in the context — e.g. using '@param:x@' (job-only prefix) in a workspace expression, or a script name that does not exist / returned a null result path.","commonSituations":"Copying job-variable expressions into workspace interpolation; referencing a script that was renamed or lives in a different project; typos in built-in variable names; assuming custom variables are available without a resolver.","solutions":["Use a variable form supported by the workspace interpolator (built-ins or an existing script name).","Ensure the referenced Groovy script exists and is resolvable in the build context if using script variables.","Escape literal @ as @@ when the '@' is not meant to start a variable reference.","Move job-only prefixes (param/property/secret) to the appropriate interpolator context."],"exampleFix":"// before (workspace context)\nString expr = \"@param:version@\";\n// after: use a supported workspace variable or script\nString expr = \"@version@\"; // built-in, or a script named 'version' in context","handlingStrategy":"validation","validationCode":"boolean scriptExists(BuildContext context, String name) {\n    try {\n        GroovyUtils.evalScriptByName(name, context);\n        return true;\n    } catch (Exception e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    value = workspaceInterpolator.interpolate(expr);\n} catch (ExplicitException e) {\n    if (e.getMessage().startsWith(\"Unrecognized interpolation variable\")) {\n        // use a supported workspace variable or define the script\n    } else throw e;\n}","preventionTips":["Use only built-in workspace variables or existing script names in workspace expressions.","Keep scripts referenced by expressions present in the project context.","Escape literal @ as @@."],"tags":["ci-cd","interpolation","undefined-variable"],"backgroundTag":"invalid-enum-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}