{"record":{"id":"c54ff7bd9bbdbc94","repo":"babalae/better-genshin-impact","slug":"manifest-json-version-is-required","errorCode":null,"errorMessage":"manifest.json: version is required.","messagePattern":"manifest\\.json: version is required\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Project/Manifest.cs","lineNumber":46,"sourceCode":"    public string[] SavedFiles { get; set; } = [];\n    public string[] HttpAllowedUrls { get; set; } = [];\n\n    public static Manifest FromJson(string json)\n    {\n        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    }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Project/Manifest.cs#L28-L64","documentation":"Thrown by Manifest.Validate when the Version property is null, empty, or whitespace after deserialization. The manifest.json must contain a non-empty 'version' field. This is the second validation check, following the Name check.","triggerScenarios":"Loading a script project whose manifest.json is missing the 'version' field or has it set to null/empty/whitespace. Manifest.Validate(path) is called from the ScriptProject constructor.","commonSituations":"A script package template omitted the version field. The version was manually deleted during editing. Migrating from an older manifest format that didn't require version.","solutions":["Open manifest.json and add a 'version' field: \"version\": \"1.0.0\".","Follow semantic versioning (semver) format for the version string.","Use a complete manifest template when creating new scripts."],"exampleFix":"// manifest.json before\n{ \"name\": \"my-script\", \"main\": \"main.js\" }\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.Version))\n    throw new InvalidOperationException(\"manifest.json must have a non-empty 'version' field\");","typeGuard":null,"tryCatchPattern":"try\n{\n    manifest.Validate(projectPath);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"version is required\"))\n{\n    TaskControl.Logger.LogError(\"Script manifest missing version field\");\n}","preventionTips":["Always include 'version' in manifest.json (use semver format like '1.0.0').","Use a manifest template with all required fields.","Run manifest validation as part of script packaging."],"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"}