Skip to content

model: fix case-insensitive suffix matching and skip .bak files in ListFilesInModelPath#10306

Merged
mudler merged 1 commit into
mudler:masterfrom
pos-ei-don:fix/model-loader-skip-bak-cachedir-tag
Jun 13, 2026
Merged

model: fix case-insensitive suffix matching and skip .bak files in ListFilesInModelPath#10306
mudler merged 1 commit into
mudler:masterfrom
pos-ei-don:fix/model-loader-skip-bak-cachedir-tag

Conversation

@pos-ei-don

@pos-ei-don pos-ei-don commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Problem

When huggingface_hub downloads models into LocalAIs models directory, it creates a CACHEDIR.TAG file. This file shows up in /v1/models because the suffix skip list contains .tag (lowercase), but strings.HasSuffix is case-sensitive — CACHEDIR.TAG (uppercase) is therefore not matched.

Additionally, backup files like model.yaml.bak-pre-gpumem072 appear in /v1/models. These are created e.g. when LocalAI backs up YAML configs before modifying them.

Fix

  1. Case-insensitive suffix matching: The filename is lowercased once with strings.ToLower before comparing against entries in knownModelsNameSuffixToSkip. This makes .tag match CACHEDIR.TAG and similar variants.
  2. .bak detection via contains-check: Backup files with suffixes like .bak-pre-gpumem072 do not end exactly in .bak, so an additional strings.Contains(lowerName, ".bak") check is added.
  3. Cleanup: The duplicate .MD entry is removed (now redundant via case-insensitive .md matching). .DS_Store is replaced by lowercased .ds_store.

Reproduction

$ curl http://localhost:8080/v1/models | jq '.data[].id'
"CACHEDIR.TAG"
"coder.yaml.bak-pre-gpumem072"
"gemma4-12b.yaml.bak-pre-gpulayers"
...

Affects any installation that uses huggingface_hub for model downloads or has YAML backup files in the models directory.

@mudler
mudler merged commit cf9debf into mudler:master Jun 13, 2026
1 check failed
@pos-ei-don
pos-ei-don deleted the fix/model-loader-skip-bak-cachedir-tag branch June 15, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants