Skip to content

Fix Models local register 500 INTERNAL_ERROR on Windows - #30

Merged
XYAIStudio merged 2 commits into
mainfrom
cursor/fix-local-model-register-500-ba8a
Sep 16, 2026
Merged

XYAIStudio merged 2 commits into
mainfrom
cursor/fix-local-model-register-500-ba8a

Conversation

@XYAIStudio

@XYAIStudio XYAIStudio commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Registering any local model from Models → LocalHardwarePanel returned a generic INTERNAL_ERROR 500. That was a shared register-path bug, not a bad GGUF.

Root causes:

  1. ollama create Modelfile wrote FROM C:\Users\...\file.gguf without quotes. Backslashes/spaces break Ollama on Windows, so every GGUF import failed.
  2. CLI output used text=True without encoding="utf-8" / errors="replace". On Chinese Windows (GBK) a failed ollama create raised UnicodeDecodeError, which is not OSError, so the API swallowed it as INTERNAL_ERROR.
  3. OllamaModelManager.list_models() called .get() on the modern SDK ListResponse object. Probe already caught that (UI still showed “Ollama 已启用”); register did not, so a successful create still 500’d.
  4. Already-pulled Ollama tags could not be registered (source=ollama was treated as “manual”, empty path failed validation, UI hid the button).

Fixes:

  • Quoted POSIX FROM line + cwd = weight parent + UTF-8 CLI decode.
  • Normalize ollama.list() dict and pydantic payloads.
  • Register already-listed Ollama tags into the provider without ollama create.
  • Recoverable failures return {ok: false, next_step} or LOCAL_MODEL_REGISTER_FAILED (400) with the real reason. Provider reload after a successful save no longer fails the request.

Target branch

  • Base is develop (feature / fix — default)
  • Base is main (requested: bugfix from latest main; do not merge / do not touch Release)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / chore
  • Release / hotfix

Test plan

  • Added/updated tests
  • uv run pytest tests/unit/test_local_register.py tests/unit/test_ollama_create.py tests/unit/api/test_local_models_register.py tests/unit/i18n/test_errors.py
  • make lint + make typecheck
  • make all (full suite not run in this environment)

Windows desktop verification (Ollama running)

  1. Confirm the tray / http://127.0.0.1:11434 is up. Models page should show Ollama 已启用.
  2. Already-pulled tag: an installed Ollama model should show 注册. Click it — it should succeed and become selectable in chat. No ollama create needed.
  3. GGUF: search/pick a file such as C:\Users\<you>\Downloads\*.gguf (spaces in the path are fine) → 注册. Should import via ollama create and then appear on the local provider.
  4. Recoverable failures (missing file, ollama create stderr, permissions) must show the real reason, not 服务器内部错误。

Checklist

  • Updated CHANGELOG.md (if user-facing)
  • README / docs updated (if needed)

Do not merge this PR and do not replace or cut a Release.

Open in Web Open in Cursor 

cursoragent and others added 2 commits September 16, 2026 07:31
Ollama create used an unquoted Windows FROM path and decoded CLI
output with the locale codec, while list_models assumed a dict. Those
failures escaped as opaque INTERNAL_ERROR. Quote POSIX FROM lines,
decode UTF-8, accept SDK list payloads, register already-pulled tags,
and return LOCAL_MODEL_REGISTER_FAILED with the real reason.

Co-authored-by: XYAI Labs <haoboy8@gmail.com>
Co-authored-by: XYAI Labs <haoboy8@gmail.com>
@XYAIStudio
XYAIStudio marked this pull request as ready for review September 16, 2026 07:32
@XYAIStudio
XYAIStudio merged commit 56ea3df into main Sep 16, 2026
5 checks passed
@XYAIStudio
XYAIStudio deleted the cursor/fix-local-model-register-500-ba8a branch September 16, 2026 08:03
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