{"record":{"id":"7b9086c0389cc016","repo":"babalae/better-genshin-impact","slug":"manifest-json-main-script-is-required","errorCode":null,"errorMessage":"manifest.json: main script is required.","messagePattern":"manifest\\.json: main script is required\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Project/Manifest.cs","lineNumber":51,"sourceCode":"        var manifest = JsonSerializer.Deserialize<Manifest>(json, Global.ManifestJsonOptions) ?? throw new Exception(\"Failed to deserialize JSON.\");\n        return manifest;\n    }\n\n    public void Validate(string path)\n    {\n        if (string.IsNullOrWhiteSpace(Name))\n        {\n            throw new Exception(\"manifest.json: name is required.\");\n        }\n\n        if (string.IsNullOrWhiteSpace(Version))\n        {\n            throw new Exception(\"manifest.json: version is required.\");\n        }\n\n        if (string.IsNullOrWhiteSpace(Main))\n        {\n            throw new Exception(\"manifest.json: main script is required.\");\n        }\n\n        if (!File.Exists(Path.Combine(path, Main)))\n        {\n            throw new FileNotFoundException(\"main js file not found.\");\n        }\n\n        // 比较版本号大小 BgiVersion\n        if (!string.IsNullOrWhiteSpace(BgiVersion) && Global.IsNewVersion(BgiVersion))\n        {\n            TaskControl.Logger.LogError(\"脚本 {Name} 版本号要求 {BgiVersion} 大于当前 BetterGI 版本号 {CurrentVersion} ， 脚本可能无法正常工作，请更新 BetterGI 版本！\", Name, BgiVersion, Global.Version);\n        }\n    }\n\n    public List<SettingItem> LoadSettingItems(string path)\n    {\n        if (string.IsNullOrWhiteSpace(SettingsUi))\n        {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Project/Manifest.cs#L33-L69","documentation":"Thrown by Manifest.Validate when the Main property (entry-point script filename) is null, empty, or whitespace after deserialization. The manifest.json must specify a main JS file that serves as the script entry point. This is the third validation check.","triggerScenarios":"Loading a script project whose manifest.json is missing the 'main' field or has it set to null/empty/whitespace. Manifest.Validate(path) is called from the ScriptProject constructor.","commonSituations":"A script package was created without specifying the entry-point file. The main field was accidentally removed during editing. Incomplete manifest from a broken packaging process.","solutions":["Open manifest.json and add a 'main' field pointing to the entry JS file: \"main\": \"main.js\".","Ensure the main field value is a relative filename, not an absolute path.","Verify the referenced file actually exists (a subsequent check validates file existence)."],"exampleFix":"// manifest.json before\n{ \"name\": \"my-script\", \"version\": \"1.0.0\" }\n// after\n{ \"name\": \"my-script\", \"version\": \"1.0.0\", \"main\": \"main.js\" }","handlingStrategy":"validation","validationCode":"var manifest = Manifest.FromJson(json);\nif (string.IsNullOrWhiteSpace(manifest.Main))\n    throw new InvalidOperationException(\"manifest.json must have a non-empty 'main' field\");","typeGuard":null,"tryCatchPattern":"try\n{\n    manifest.Validate(projectPath);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"main script is required\"))\n{\n    TaskControl.Logger.LogError(\"Script manifest missing main field\");\n}","preventionTips":["Always include 'main' in manifest.json pointing to the entry-point JS file.","Verify the main field value matches the actual entry-point filename.","Use a complete manifest template when scaffolding new scripts."],"tags":["manifest","validation","script-project","configuration"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}