{"record":{"id":"b3faf61d5d0b263b","repo":"OrchardCMS/OrchardCore","slug":"unknown-command-script","errorCode":null,"errorMessage":"Unknown command '{script}'","messagePattern":"Unknown command '(.+?)'","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Infrastructure/Scripting/Files/FilesScriptEngine.cs","lineNumber":57,"sourceCode":"        else if (script.StartsWith(\"base64('\", StringComparison.Ordinal) && script.EndsWith(\"')\", StringComparison.Ordinal))\n        {\n            var filePath = script[8..^2];\n            var fileInfo = fileScope.FileProvider.GetRelativeFileInfo(fileScope.BasePath, filePath);\n            if (!fileInfo.Exists)\n            {\n                throw new FileNotFoundException(filePath);\n            }\n\n            using var fileStream = fileInfo.CreateReadStream();\n            using var memoryStream = MemoryStreamFactory.GetStream();\n            memoryStream.WriteTo(fileStream);\n            memoryStream.Seek(0, SeekOrigin.Begin);\n\n            return Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length);\n        }\n        else\n        {\n            throw new ArgumentException($\"Unknown command '{script}'\");\n        }\n    }\n}\n","sourceCodeStart":39,"sourceCodeEnd":61,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Infrastructure/Scripting/Files/FilesScriptEngine.cs#L39-L61","documentation":"Evaluate in the Files scripting engine fell through all known script forms ('base64(...)' and other prefixes) and reached the final else branch, meaning the script string did not match any supported command syntax. The offending input is the script expression itself, e.g. a typo'd or unsupported command name.","triggerScenarios":"Calling Evaluate on the Files engine with a script that is neither text('...') nor base64('...') — e.g. bare paths, wrong quotes, extra whitespace, or scripts meant for another engine (JS, Liquid).","commonSituations":"Authoring script strings with double quotes instead of single quotes; passing expressions like shell('...') or js('...') to the Files engine; trailing spaces breaking the EndsWith check.","solutions":["Rewrite the script to the exact form text('path') or base64('path') with single quotes and no extra whitespace.","If the script is JavaScript or Liquid, route it to the appropriate IScriptingEngine instead of the Files engine.","Validate/normalize the script string (trim, correct quoting) before calling Evaluate."],"exampleFix":"// before\nengine.Evaluate(scope, \"text(\\\"file.txt\\\")\"); // wrong quotes -> unknown command\n// after\nengine.Evaluate(scope, \"text('file.txt')\");","handlingStrategy":"validation","validationCode":"var ok = (script.StartsWith(\"text('\") && script.EndsWith(\"')\")) ||\n         (script.StartsWith(\"base64('\") && script.EndsWith(\"')\"));\nif (!ok) throw new FormatException(\"Files scripts must be text('path') or base64('path').\");","typeGuard":null,"tryCatchPattern":"try { result = engine.Evaluate(scope, script); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Unknown command\")) { /* route to the correct engine */ }","preventionTips":["Use single quotes and no surrounding whitespace in Files scripts","Only send text()/base64() scripts to FilesScriptEngine","Dispatch scripts by prefix to the right IScriptingEngine"],"tags":["scripting","parsing","invalid-argument-format","unsupported-operation"],"backgroundTag":"invalid-argument-format","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}