JosefNemec/Playnite · error · ArgumentNullException

Game script is not defined.

Error message

Game script is not defined.

What it means

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.

Source

Thrown at source/Playnite/Controllers/GenericGameController.cs:504

            }

            if (playAction.Type == GameActionType.Emulator)
            {
                throw new Exception("Cannot start emulator using this configuration.");
            }

            StartingArgs = startingArgs;
            var gameClone = Game.GetClone();
            var action = playAction.GetClone();
            action = action.ExpandVariables(gameClone);
            action.Path = CheckPath(action.Path, nameof(action.Path), FileSystemItem.File);
            action.WorkingDir = CheckPath(action.WorkingDir, nameof(action.WorkingDir), FileSystemItem.Directory);

            if (playAction.Type == GameActionType.Script)
            {
                if (action.Script.IsNullOrWhiteSpace())
                {
                    throw new ArgumentNullException("Game script is not defined.");
                }

                action.Script = Game.ExpandVariables(action.Script, false);
                RunStartScript(
                    $"{Game.Name} play script",
                    action.Script,
                    gameClone.ExpandVariables(gameClone.InstallDirectory, true),
                    new Dictionary<string, object>(),
                    asyncExec);
            }
            else
            {
                Process proc;
                if (action.Type == GameActionType.File)
                {
                    proc = ProcessStarter.StartProcess(action.Path, action.Arguments, action.WorkingDir);
                }
                else if (action.Type == GameActionType.URL)

View on GitHub (pinned to 5911f4e964)

Solutions

  1. Open the game's edit dialog, go to the play action, and enter a valid script in the Script field.
  2. If the script is not needed, change the action type to File or URL.
  3. If migrating data, verify that script fields are included in the migration mapping.
  4. Delete the empty script action and recreate it with content.

Example fix

// before — script action with empty body
var action = new GameAction { Type = GameActionType.Script, Script = null };
controller.Start(action, true, startingArgs);

// after — validate before starting
if (action.Type == GameActionType.Script && action.Script.IsNullOrWhiteSpace())
{
    logger.Warn($"Game '{game.Name}' has an empty script action.");
    return;
}
controller.Start(action, true, startingArgs);
Defensive patterns

Strategy: validation

Validate before calling

if (action.Type == GameActionType.Script && action.Script.IsNullOrWhiteSpace())
{
    logger.Warn($"Script action for '{game.Name}' has no script body.");
    return;
}

Type guard

static bool HasValidScriptBody(GameAction action)
{
    return action.Type != GameActionType.Script ||
           !action.Script.IsNullOrWhiteSpace();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13). Data as JSON: /api/errors/2b8b0eeca8b92201. Report an issue: GitHub.