Skip to content

fix(engine): fix broken URL resolution in Ollama and MLX engines#547

Merged
di-sukharev merged 1 commit intodi-sukharev:masterfrom
keith666666:fix/ollama-url-resolution
Apr 3, 2026
Merged

fix(engine): fix broken URL resolution in Ollama and MLX engines#547
di-sukharev merged 1 commit intodi-sukharev:masterfrom
keith666666:fix/ollama-url-resolution

Conversation

@keith666666
Copy link
Copy Markdown
Contributor

Summary

Both OllamaEngine and MLXEngine produce malformed URLs when making API requests, causing HTTP 405 errors.

Root cause — two bugs in URL construction:

  1. axios.create({ url: ... }) was used instead of baseURL. In axios, url sets a default request URL, not a base prefix — so it gets ignored when .post(path, data) is called separately.

  2. this.client.getUri(this.config) was used to resolve the POST URL, but the engine config contains non-axios properties (apiKey, model, maxTokensOutput, etc.) that pollute URL resolution. When apiKey is null (the default for Ollama), the URL resolves to http://localhost:11434/null, which returns HTTP 405.

Fix: Construct the full endpoint URL once in the constructor and pass it directly to axios.post() — matching how FlowiseEngine already works.

Before (broken)

this.client = axios.create({
  url: config.baseURL
    ? `${config.baseURL}/${config.apiKey}`  // → "http://localhost:11434/null"
    : 'http://localhost:11434/api/chat',
});

// getUri merges non-axios config properties → malformed URL
const response = await this.client.post(
  this.client.getUri(this.config), params
);

After (fixed)

this.chatUrl = `${config.baseURL || 'http://localhost:11434'}/api/chat`;
this.client = axios.create({ headers });

const response = await this.client.post(this.chatUrl, params);

Test plan

  • npm test — all 37 unit tests pass
  • npm run build — builds successfully
  • Verified end-to-end with Ollama (qwen3.5:2b) — commit message generated successfully

Both OllamaEngine and MLXEngine had two bugs in URL construction:

1. `axios.create({url: ...})` was used instead of `baseURL`, but `url`
   in axios config sets a default request URL - not a base prefix. This
   caused the URL to be ignored when `.post()` was called with a path.

2. `this.client.getUri(this.config)` was used to resolve the POST URL,
   but passing the engine config (which contains non-axios properties
   like `apiKey`, `model`, etc.) produced malformed URLs. When
   `apiKey` is null (the default for Ollama), the URL resolved to
   `http://localhost:11434/null`, returning HTTP 405.

Fix: construct the full endpoint URL once in the constructor and pass
it directly to `axios.post()`, matching how FlowiseEngine already works.

Co-Authored-By: Claude <noreply@anthropic.com>
@di-sukharev di-sukharev merged commit a9c9bcf into di-sukharev:master Apr 3, 2026
6 checks passed
@di-sukharev
Copy link
Copy Markdown
Owner

thank you @keith666666

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