{"record":{"id":"5a5b2cc0abd8275b","repo":"JosefNemec/Playnite","slug":"cannot-start-game-without-play-action","errorCode":null,"errorMessage":"Cannot start game without play action.","messagePattern":"Cannot start game without play action\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"source/Playnite/Controllers/GenericGameController.cs","lineNumber":485,"sourceCode":"                WorkingDir = controller.WorkingDir,\r\n                TrackingMode = controller.TrackingMode,\r\n                TrackingPath = controller.TrackingPath,\r\n                InitialTrackingDelay = controller.InitialTrackingDelay,\r\n                TrackingFrequency = controller.TrackingFrequency\r\n            };\r\n\r\n            Start(action, true, new OnGameStartingEventArgs\r\n            {\r\n                SourceAction = action,\r\n                Game = Game\r\n            });\r\n        }\r\n\r\n        public void Start(GameAction playAction, bool asyncExec, OnGameStartingEventArgs startingArgs)\r\n        {\r\n            if (playAction == null)\r\n            {\r\n                throw new ArgumentNullException(\"Cannot start game without play action.\");\r\n            }\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","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Controllers/GenericGameController.cs#L467-L503","documentation":"Thrown as ArgumentNullException when the Start(GameAction playAction, ...) method receives a null playAction. This is a programming-contract violation: the caller must supply a valid GameAction before invoking start. The Start method at this signature is the non-emulator entry point and playAction is its mandatory input.","triggerScenarios":"Game.GameActions is empty or the play action was never assigned, so the controller calls Start(null, ...). A plugin or script programmatically invokes PlayniteController.Start with a null action. A game's default play action was deleted but the game was still launched.","commonSituations":"The game has no actions defined and no default play action set. A metadata import cleared the Actions collection. A user script or extension calls the start API incorrectly. The game object is in a partially-initialized state after a database migration.","solutions":["Assign a play action to the game: open the game's edit dialog and configure a valid play action (File, URL, or Script).","If calling Start programmatically, always null-check the action before invoking: if (game.GameActions?.Any() != true) return;","Verify the game's Actions collection is populated after metadata imports or migrations.","Set a default action via the game editor's 'Play' tab before launching."],"exampleFix":"// before — launching a game whose play action is null\ncontroller.Start(game.PlayAction, true, startingArgs);\n\n// after — guard before calling Start\nvar action = game.PlayAction ?? game.GameActions?.FirstOrDefault(a => a.IsPlayAction);\nif (action == null)\n{\n    logger.Warn($\"Game '{game.Name}' has no play action.\");\n    return;\n}\ncontroller.Start(action, true, startingArgs);","handlingStrategy":"validation","validationCode":"if (game.PlayAction == null && (game.GameActions?.Any(a => a.IsPlayAction) != true))\n{\n    logger.Warn($\"Game '{game.Name}' has no play action.\");\n    return;\n}","typeGuard":"static bool HasValidPlayAction(Game game)\n{\n    return game.PlayAction != null ||\n           (game.GameActions?.Any(a => a.IsPlayAction) == true);\n}","tryCatchPattern":"try\n{\n    controller.Start(action, true, startingArgs);\n}\ncatch (ArgumentNullException ex) when (ex.Message.Contains(\"play action\"))\n{\n    logger.Error($\"Attempted to start game without a play action: {game.Name}\");\n    Dialogs.ShowMessage(\"This game has no play action configured.\");\n}","preventionTips":["Always null-check the play action before calling Start.","Validate game action configuration during game import/edit.","Display a warning in the UI when a game has no play action instead of allowing launch."],"tags":["play-action","argument-null","game-start","validation"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}