LykosAI/StabilityMatrix · error · ApplicationException

Model does not exist in index

Error message

Model {network.Name} does not exist in index

What it means

During GetExtraNetworksAsLocalModels(), each extra network's type is converted to a SharedFolderType and looked up in the model index. If the index has no models registered for that folder type, the method throws ApplicationException naming the network. The whole category of models (e.g. Lora) is absent from the index.

Solutions

  1. Refresh the model index (IModelIndexService.RefreshIndex) before running inference.
  2. Ensure the referenced model type's shared folder exists and models are installed/imported.
  3. Check indexService.ModelIndex.ContainsKey(sharedFolderType) before resolving, and skip unknown networks.
  4. Wait for initial index build completion before enabling inference features.

Example fix

// before
foreach (var net in prompt.ExtraNetworks) { /* resolve */ }
// after
await indexService.RefreshIndex();
var models = prompt
    .GetExtraNetworksAsLocalModels(indexService)
    .Where(t => t.LocalModel is not null);
Defensive patterns

Strategy: validation

Validate before calling

await indexService.RefreshIndex();
var hasType = indexService.ModelIndex.ContainsKey(network.Type.ConvertTo<SharedFolderType>());

Type guard

bool TypeIndexed(IModelIndexService s, SharedFolderType t) => s.ModelIndex.TryGetValue(t, out _);

Try / catch

try { models = prompt.GetExtraNetworksAsLocalModels(indexService); }
catch (ApplicationException ex) { NotifyUserModelIndexIncomplete(ex.Message); }

Prevention

When it happens

Trigger: An extra network like <lora:foo> whose SharedFolderType bucket has no entry in indexService.ModelIndex — e.g. the index was never built/refreshed, or the model type's shared folder is not configured.

Common situations: Fresh install or new shared-folder mode where the model index has not been refreshed; invoking inference before the index service finished scanning; prompts copied from another setup referencing model types not available locally.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/ecec43b171c2e06f. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Avalonia/Models/Inference/Prompt.cs:86

        LocalModelFile ModelFile,
        double? ModelWeight,
        double? ClipWeight
    )> GetExtraNetworksAsLocalModels(IModelIndexService indexService)
    {
        if (ExtraNetworks is null)
        {
            throw new InvalidOperationException(
                "Prompt must be processed before calling GetExtraNetworksAsLocalModels"
            );
        }

        foreach (var network in ExtraNetworks)
        {
            var sharedFolderType = network.Type.ConvertTo<SharedFolderType>();

            if (!indexService.ModelIndex.TryGetValue(sharedFolderType, out var modelList))
            {
                throw new ApplicationException($"Model {network.Name} does not exist in index");
            }

            var localModel = modelList.FirstOrDefault(m => m.FileNameWithoutExtension == network.Name);
            if (localModel == null)
            {
                throw new ApplicationException($"Model {network.Name} does not exist in index");
            }

            yield return (localModel, network.ModelWeight, network.ClipWeight);
        }
    }

    private int GetSafeEndIndex(int index)
    {
        return Math.Min(index, RawText.Length);
    }

    private (List<PromptExtraNetwork> promptExtraNetworks, string processedText) GetExtraNetworks(

View on GitHub (pinned to af93d6ef57)