babalae/better-genshin-impact · warning · InvalidOperationException
添加流程步骤后不能修改流程默认配置
Error message
添加流程步骤后不能修改流程默认配置
What it means
Thrown when the image URI's scheme is not one of the supported schemes: data, file, pack, http, or https. The final else branch in LoadAsync catches all other schemes (e.g. ftp, blob, custom) with a NotSupportedException naming the unrecognized scheme.
Source
Thrown at BetterGenshinImpact/Core/BgiVision/BvFlow.cs:474
lock (_syncRoot)
{
if (_hasStarted)
{
throw new InvalidOperationException("BvFlow 已经开始执行,不能再添加步骤");
}
_hasSteps = true;
_steps.Add(new BvFlowStep(description, action));
}
return this;
}
private void EnsureDefaultsCanChange()
{
if (_hasSteps)
{
throw new InvalidOperationException("添加流程步骤后不能修改流程默认配置");
}
}
private sealed record BvFlowStep(string Description, Func<BvFlowExecutionContext, Task> Action);
}
internal sealed record BvFlowConditionResult(bool Succeeded, Region? Match);
internal sealed class BvFlowExecutionContext
{
public Rect? LastMatchRect { get; set; }
public (double X, double Y) GetLastMatchCenter()
{
if (LastMatchRect is not { } rect)
{
throw new InvalidOperationException("没有可用的上一步识别位置,无法执行隐式坐标操作");View on GitHub (pinned to a7cb36712d)
Solutions
- Convert the image reference to a supported scheme (http, https, data, or local file path).
- If a custom scheme is needed, subclass MarkdownImageLoader and add a branch for it.
- Pre-validate image URIs in the Markdown parser before passing to LoadAsync.
Example fix
// before
else
{
throw new NotSupportedException($"不支持的图片协议:{source.Scheme}");
}
// after — degrade gracefully with diagnostic
else
{
_owner.ReportDiagnostic(new MarkdownDiagnostic(MarkdownDiagnosticSeverity.Warning,
$"不支持的图片协议:{source.Scheme},已跳过。"));
return MarkdownImageResult.Placeholder;
} Defensive patterns
Strategy: validation
Validate before calling
// Validate scheme before loading
var scheme = source.Scheme.ToLowerInvariant();
if (scheme is not ("data" or "file" or "pack" or "http" or "https"))
return MarkdownImageResult.Placeholder; Type guard
static bool IsSupportedScheme(Uri source) =>
source.Scheme.ToLowerInvariant() is "data" or "file" or "pack" or "http" or "https"; Try / catch
try { /* load */ }
catch (NotSupportedException) { return MarkdownImageResult.Placeholder; } Prevention
- Filter image URIs to supported schemes in the Markdown parser.
- Subclass MarkdownImageLoader to add custom schemes if needed.
- Validate URIs before passing to LoadAsync.
When it happens
Trigger: LoadAsync receives a Uri whose Scheme is not data/file/pack/http/https. Triggered by Markdown referencing an image with an unsupported protocol like ftp://, ws://, or a custom-virtual scheme injected by a script.
Common situations: Script-generated Markdown uses a custom URI scheme, a typo produces a malformed scheme, or a content source uses a protocol this loader doesn't support (e.g. ftp).
Related errors
- 等待 {targetDescription} 超时({timeout}ms)
- 没有可用的上一步识别位置,无法执行隐式坐标操作
- milliseconds 不能小于 0
- 一次性动作不支持 WithTimeout 或 WithRetryInterval,请使用 Until 系列方法设置重试条
- 当前动作已经设置完成条件,不能再次修改或添加
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/c06312216b76636b.
Report an issue: GitHub.