{"record":{"id":"2b8b0eeca8b92201","repo":"JosefNemec/Playnite","slug":"game-script-is-not-defined","errorCode":null,"errorMessage":"Game script is not defined.","messagePattern":"Game script is not defined\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"source/Playnite/Controllers/GenericGameController.cs","lineNumber":504,"sourceCode":"            }\r\n\r\n            if (playAction.Type == GameActionType.Emulator)\r\n            {\r\n                throw new Exception(\"Cannot start emulator using this configuration.\");\r\n            }\r\n\r\n            StartingArgs = startingArgs;\r\n            var gameClone = Game.GetClone();\r\n            var action = playAction.GetClone();\r\n            action = action.ExpandVariables(gameClone);\r\n            action.Path = CheckPath(action.Path, nameof(action.Path), FileSystemItem.File);\r\n            action.WorkingDir = CheckPath(action.WorkingDir, nameof(action.WorkingDir), FileSystemItem.Directory);\r\n\r\n            if (playAction.Type == GameActionType.Script)\r\n            {\r\n                if (action.Script.IsNullOrWhiteSpace())\r\n                {\r\n                    throw new ArgumentNullException(\"Game script is not defined.\");\r\n                }\r\n\r\n                action.Script = Game.ExpandVariables(action.Script, false);\r\n                RunStartScript(\r\n                    $\"{Game.Name} play script\",\r\n                    action.Script,\r\n                    gameClone.ExpandVariables(gameClone.InstallDirectory, true),\r\n                    new Dictionary<string, object>(),\r\n                    asyncExec);\r\n            }\r\n            else\r\n            {\r\n                Process proc;\r\n                if (action.Type == GameActionType.File)\r\n                {\r\n                    proc = ProcessStarter.StartProcess(action.Path, action.Arguments, action.WorkingDir);\r\n                }\r\n                else if (action.Type == GameActionType.URL)\r","sourceCodeStart":486,"sourceCodeEnd":522,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Controllers/GenericGameController.cs#L486-L522","documentation":"Thrown as ArgumentNullException when a game action has Type=GameActionType.Script but its Script property is null or whitespace. The controller enters the script branch and immediately validates that the script body exists before attempting variable expansion and execution. A script action with no script content is an incomplete or corrupt configuration.","triggerScenarios":"A game is configured with a Script-type play action where the Script field was left empty or was cleared. A metadata import or database migration set the action type to Script without populating the Script field. A user created a script action but never wrote the script body.","commonSituations":"User created a new script action but forgot to enter the script content. A game configuration was imported from another source that supports script-type actions but the script body was not transferred. A database corruption or manual edit cleared the Script property.","solutions":["Open the game's edit dialog, go to the play action, and enter a valid script in the Script field.","If the script is not needed, change the action type to File or URL.","If migrating data, verify that script fields are included in the migration mapping.","Delete the empty script action and recreate it with content."],"exampleFix":"// before — script action with empty body\nvar action = new GameAction { Type = GameActionType.Script, Script = null };\ncontroller.Start(action, true, startingArgs);\n\n// after — validate before starting\nif (action.Type == GameActionType.Script && action.Script.IsNullOrWhiteSpace())\n{\n    logger.Warn($\"Game '{game.Name}' has an empty script action.\");\n    return;\n}\ncontroller.Start(action, true, startingArgs);","handlingStrategy":"validation","validationCode":"if (action.Type == GameActionType.Script && action.Script.IsNullOrWhiteSpace())\n{\n    logger.Warn($\"Script action for '{game.Name}' has no script body.\");\n    return;\n}","typeGuard":"static bool HasValidScriptBody(GameAction action)\n{\n    return action.Type != GameActionType.Script ||\n           !action.Script.IsNullOrWhiteSpace();\n}","tryCatchPattern":null,"preventionTips":["Validate script actions in the game editor UI before saving.","When importing game metadata, skip or warn on script actions with empty bodies.","Add a UI placeholder/hint in the script editor prompting the user to enter content."],"tags":["script-action","argument-null","play-action","validation","game-start"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}