babalae/better-genshin-impact · error · Exception
manifest.json: name is required.
Error message
manifest.json: name is required.
What it means
Thrown by Manifest.Validate when the Name property is null, empty, or whitespace after deserialization. The manifest.json must contain a non-empty 'name' field identifying the script package. This is the first validation check in the Validate method.
Source
Thrown at BetterGenshinImpact/Core/Script/Project/Manifest.cs:41
public List<Author> Authors { get; set; } = [];
public string Main { get; set; } = string.Empty;
public string SettingsUi { get; set; } = string.Empty;
public string[] Scripts { get; set; } = [];
public string[] Library { get; set; } = [];
public string[] SavedFiles { get; set; } = [];
public string[] HttpAllowedUrls { get; set; } = [];
public static Manifest FromJson(string json)
{
var manifest = JsonSerializer.Deserialize<Manifest>(json, Global.ManifestJsonOptions) ?? throw new Exception("Failed to deserialize JSON.");
return manifest;
}
public void Validate(string path)
{
if (string.IsNullOrWhiteSpace(Name))
{
throw new Exception("manifest.json: name is required.");
}
if (string.IsNullOrWhiteSpace(Version))
{
throw new Exception("manifest.json: version is required.");
}
if (string.IsNullOrWhiteSpace(Main))
{
throw new Exception("manifest.json: main script is required.");
}
if (!File.Exists(Path.Combine(path, Main)))
{
throw new FileNotFoundException("main js file not found.");
}
// 比较版本号大小 BgiVersionView on GitHub (pinned to a7cb36712d)
Solutions
- Open manifest.json and add a non-empty 'name' field: "name": "my-script-name".
- Use a valid manifest template as a starting point for new scripts.
- Validate manifest.json with a JSON schema before loading.
Example fix
// manifest.json before
{ "version": "1.0.0", "main": "main.js" }
// after
{ "name": "my-script", "version": "1.0.0", "main": "main.js" } Defensive patterns
Strategy: validation
Validate before calling
var manifest = Manifest.FromJson(json);
if (string.IsNullOrWhiteSpace(manifest.Name))
throw new InvalidOperationException("manifest.json must have a non-empty 'name' field"); Try / catch
try
{
manifest.Validate(projectPath);
}
catch (Exception ex) when (ex.Message.Contains("name is required"))
{
TaskControl.Logger.LogError("Script manifest missing name field");
} Prevention
- Always include 'name' in manifest.json when creating new script packages.
- Use a manifest template with all required fields pre-filled.
- Validate manifest.json structure before loading scripts.
When it happens
Trigger: Loading a script project whose manifest.json is missing the 'name' field entirely, or has it set to null/empty string/whitespace-only. Manifest.Validate(path) is called from ScriptProject constructor after deserialization.
Common situations: A new script package was created from a template that didn't include the name field. The manifest was hand-edited and the name was accidentally deleted. An incomplete or corrupted manifest.json.
Related errors
- manifest.json: version is required.
- manifest.json: main script is required.
- main js file not found.
- 从 library 字段读取路径 '{path}' 失败: {ex.Message}
- Failed to deserialize JSON.
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/d3e5c4e6f6a59ca2.
Report an issue: GitHub.