babalae/better-genshin-impact · error · Exception

地图追踪文件加载失败

Error message

地图追踪文件加载失败

What it means

Thrown by GoToAdventurersGuildTask.GoToAdventurersGuild when PathingTask.BuildFromFilePath returns null for the file GameTask\Common\Element\Assets\Json\冒险家协会_{country}.json. A null return means the pathing JSON for the requested country could not be loaded.

Source

Thrown at BetterGenshinImpact/GameTask/Common/Job/GoToAdventurersGuildTask.cs:161

        if (Bv.IsInTalkUi(talkUiCapture))
        {
            await _chooseTalkOptionTask.SelectLastOptionUntilEnd(ct);
            Logger.LogInformation("退出当前对话");
        }
    }

    /// <summary>
    /// 前往冒险家协会
    /// </summary>
    /// <param name="country"></param>
    /// <param name="ct"></param>
    /// <returns></returns>
    public async Task GoToAdventurersGuild(string country, CancellationToken ct)
    {
        var task = PathingTask.BuildFromFilePath(Global.Absolute(@$"GameTask\Common\Element\Assets\Json\冒险家协会_{country}.json"));
        if (task == null)
        {
            throw new Exception("地图追踪文件加载失败");
        }
        var pathingTask = new PathExecutor(ct)
        {
            PartyConfig = new PathingPartyConfig
            {
                Enabled = true,
                AutoSkipEnabled = true
            },
            EndAction = region => Bv.FindFAndPress(region, text: this.catherineLocalizedString)
        };
        await pathingTask.Pathing(task);

        await Delay(600, ct);

        const int retryTalkTimes = 3;
        for (int i = 0; i < retryTalkTimes; i++)
        {
            using var ra = CaptureToRectArea();

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Check that GameTask/Common/Element/Assets/Json/冒险家协会_{country}.json exists for the country being requested.
  2. Validate the country value against the set of shipped JSON files before calling BuildFromFilePath.
  3. If the JSON exists, validate it parses (open it in the pathing editor / check schema) — BuildFromFilePath returns null on parse failure.
  4. Confirm Global.Absolute resolves to the application base directory and the file is copied to output.

Example fix

// before
var task = PathingTask.BuildFromFilePath(Global.Absolute(@$"GameTask\Common\Element\Assets\Json\冒险家协会_{country}.json"));
if (task == null)
{
    throw new Exception("地图追踪文件加载失败");
}

// after: surface which file and why
var path = Global.Absolute(@$"GameTask\Common\Element\Assets\Json\冒险家协会_{country}.json");
var task = PathingTask.BuildFromFilePath(path);
if (task == null)
{
    throw new Exception($"地图追踪文件加载失败:{path}(文件不存在或格式无效)");
}
Defensive patterns

Strategy: validation

Validate before calling

var path = Global.Absolute(@$"GameTask\Common\Element\Assets\Json\冒险家协会_{country}.json");
if (!File.Exists(path))
    throw new FileNotFoundException($"冒险家协会路径文件缺失:{path}", path);
var task = PathingTask.BuildFromFilePath(path) ?? throw new Exception("地图追踪文件加载失败:" + path);

Type guard

static bool HasGuildPathing(string country) =>
    File.Exists(Global.Absolute($"GameTask/Common/Element/Assets/Json/冒险家协会_{country}.json"));

Try / catch

null

Prevention

When it happens

Trigger: PathingTask.BuildFromFilePath(Global.Absolute(@$"...\冒险家协会_{country}.json")) returns null. Occurs when the file does not exist for the given country value, the JSON is malformed, or Global.Absolute resolves to a path outside the deploy directory.

Common situations: The country argument is an unsupported/misspelled value (e.g. '璃月' vs '璃月港', or a region with no shipped JSON); the assets folder was not deployed with the build; the JSON was hand-edited and now fails schema deserialization; case/encoding mismatch in the filename on a case-sensitive or locale-affected FS.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/343d20eaa5464349. Report an issue: GitHub.