k1tbyte/Wand-Enhancer · error · Exception
[ENHANCER] Failed to apply patches: {failedPatches}. The ver
Error message
[ENHANCER] Failed to apply patches: {failedPatches}. The version may not be supported. What it means
After scanning every candidate bundle file, PatchAsar still has EPatchType values left in remainingPatches — meaning for at least one requested patch type, not every PatchEntry in EnhancerConfig[type] reached Applied=true (entries.All(x => x.Applied) was false). It is the aggregate 'patch did not fully land' error.
Source
Thrown at WandEnhancer/Core/Enhancer.cs:176
fileChanged = fileChanged || patchApplied;
}
if (entries.All(x => x.Applied))
{
remainingPatches.Remove(entry);
}
}
if (fileChanged)
{
File.WriteAllText(item, data);
}
}
if(remainingPatches.Count > 0)
{
var failedPatches = string.Join(", ", remainingPatches.Select(p => p.ToString()));
throw new Exception($"[ENHANCER] Failed to apply patches: {failedPatches}. The version may not be supported.");
}
}
private static bool IsCandidateBundleFile(string filePath)
{
string fileName = Path.GetFileName(filePath);
return fileName.Equals(IndexBundleFileName, StringComparison.OrdinalIgnoreCase)
|| (fileName.StartsWith(AppBundleFilePrefix, StringComparison.OrdinalIgnoreCase)
&& fileName.EndsWith(AppBundleFileSuffix, StringComparison.OrdinalIgnoreCase));
}
private static bool CouldFileContainRemainingPatch(string filePath, IEnumerable<EPatchType> remainingPatches, Dictionary<EPatchType, EnhancerConfig.PatchEntry[]> enhancerConfig)
{
foreach (var patchType in remainingPatches)
{
foreach (var patchEntry in enhancerConfig[patchType])
{
if (patchEntry.Applied)View on GitHub (pinned to 643c8f8b62)
Solutions
- Read failedPatches from the message (e.g. 'ActivatePro, DevToolsOnF12').
- For each, open its PatchEntry[] in EnhancerConfig.GetInstance() and check Target / SearchHints / CandidateFileNames.
- Re-derive the drifted regexes against the live bundle (extract app.asar, grep).
- If a patch is optional for your goal, remove that EPatchType from PatchConfig.PatchTypes.
- Otherwise upgrade/downgrade Wand to a supported release.
Example fix
// Drop an unsupported patch type from the config to unblock the rest
// before
config.PatchTypes = new HashSet<EPatchType> {
EPatchType.ActivatePro, EPatchType.DisableUpdates, EPatchType.DevToolsOnF12,
EPatchType.RemoteWebPanelPreview
};
// after (remove the one whose anchor drifted until regex is re-derived)
config.PatchTypes = new HashSet<EPatchType> {
EPatchType.ActivatePro, EPatchType.DisableUpdates,
EPatchType.RemoteWebPanelPreview
}; Defensive patterns
Strategy: try-catch
Validate before calling
// Optional dry run: report which patch types would fail to fully apply
var cfg = EnhancerConfig.GetInstance();
foreach (var type in _config.PatchTypes) {
var entries = cfg[type];
var anyMissingAnchor = entries.Any(p =>
!Directory.EnumerateFiles(_unpackedPath, "*.js", SearchOption.TopDirectoryOnly)
.Any(f => p.SearchHints == null || p.SearchHints.Any(h => File.ReadAllText(f).Contains(h))));
if (anyMissingAnchor) _logger($"WARN: {type} anchor not found in any bundle.", ELogType.Warning);
} Try / catch
try {
enhancer.Patch();
} catch (Exception ex) when (ex.Message.StartsWith("[ENHANCER] Failed to apply patches:")) {
// parse failed list, re-derive drifted regexes, or drop optional types
} Prevention
- Run patch types incrementally so one drift does not abort everything.
- Surface the per-patch Applied status in the UI before throwing the aggregate.
- Pin supported Wand versions and reject others early.
When it happens
Trigger: PatchAsar loop completes over all items in `items`; at Enhancer.cs:173 remainingPatches.Count > 0 because one or more patch types never matched (Target.Success false everywhere) or only partially applied (some entries applied, others not).
Common situations: A Wand version where some patches still work but others drifted; enabling a PatchType whose anchor method no longer exists in that build; bundle split across files so CandidateFileNames filters miss the right one.
Related errors
- [ENHANCER] [{patchType} -> {patch.Name}] Patch failed. Multi
- [ENHANCER] [{patchType} -> {patch.Name}] Resolver failed to
- {patchName} failed to resolve {groupName}
AI-assisted analysis of k1tbyte/Wand-Enhancer@643c8f8b62 (2026-08-13).
Data as JSON: /api/errors/f13952acf7bf85b0.
Report an issue: GitHub.