Skip to content

fix(console): allow Ollama custom model validation - #1576

Closed
arimu1 wants to merge 2 commits into
iflytek:mainfrom
arimu1:fix/1551-ollama-custom-model-validation
Closed

fix(console): allow Ollama custom model validation#1576
arimu1 wants to merge 2 commits into
iflytek:mainfrom
arimu1:fix/1551-ollama-custom-model-validation

Conversation

@arimu1

@arimu1 arimu1 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • Detect Ollama endpoints during custom model validation (explicit ollama provider or default port :11434 / hostname containing ollama)
  • Use a dedicated validation path: accept OpenAI-compatible chat responses without a usage field (Ollama often omits it)
  • Allow private/local endpoint addresses for Ollama by wiring the existing SsrfProperties.blockPrivate flag (previously unused) instead of rejecting loopback/LAN URLs by default

Fixes #1551

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring

Related Issue

Fixes #1551

Changes

  • ModelService.resolveValidationProvider() infers Ollama from provider/endpoint and routes to relaxed response + SSRF rules
  • ModelService.isValidModelResponse() accepts Ollama replies with choices only (no usage required)
  • ModelService.buildModelApiUrlNew() sets blockPrivate=false for Ollama endpoints
  • SsrfParamGuard honors blockPrivate: when false, only explicit IP blacklist applies (not default private-network denial)
  • Regression tests for Ollama response without usage and localhost :11434 URL building

Testing

Added:

  • ModelServiceTest.testValidateModel_ollamaResponseWithoutUsage_success
  • ModelServiceTest.buildModelApiUrlAllowsPrivateIpForOllamaEndpoint

Prove-it (bug on current main):

  1. OpenAI-compat check requires usage — see ModelService.isValidModelResponse() and existing testValidateModel_responseNotCompatible_throws which asserts missing usage is rejected.
  2. Private IP SSRF — see existing buildModelApiUrlRejectsPrivateIpWhenBlacklistIsEmpty which asserts http://192.168.x is rejected even with empty blacklist; Ollama on 127.0.0.1:11434 hit the same path.

Screenshots (if applicable)

N/A (backend validation fix)

Checklist

  • Code follows project coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Breaking changes documented

Made-with: Cursor (Composer)

Made with Cursor

Detect Ollama endpoints during model validation and use a dedicated
provider path: accept chat completion responses without a usage field
and permit private/local addresses via the existing blockPrivate SSRF
toggle instead of the strict OpenAI compatibility check.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@arimu1
arimu1 force-pushed the fix/1551-ollama-custom-model-validation branch 2 times, most recently from 5edb424 to 7a03e46 Compare July 27, 2026 09:23
Avoid reclassifying OpenAI-compat endpoints with /ollama in the path as
Ollama, which disabled private-IP SSRF blocking. Infer Ollama only from
explicit provider, hostname containing "ollama", or port 11434.
@arimu1
arimu1 force-pushed the fix/1551-ollama-custom-model-validation branch from 7a03e46 to 4d26f56 Compare July 27, 2026 09:23
@lyj715824

Copy link
Copy Markdown
Contributor

The CI is having issues—please investigate

@lyj715824

Copy link
Copy Markdown
Contributor

This issue has been fixed in PR #1562. Please deploy the latest version and give it a try. Thanks!

@lyj715824

Copy link
Copy Markdown
Contributor

START TRANSACTION;

UPDATE config_info
SET value = '192.168.xx.xx', is_valid = 1, update_time = NOW()
WHERE category = 'IP_WHITE_LIST' AND code = 'ip_white_list';

UPDATE config_info_en
SET value = '192.168.xx.xx', is_valid = 1, update_time = NOW()
WHERE category = 'IP_WHITE_LIST' AND code = 'ip_white_list';

COMMIT;

@lyj715824 lyj715824 closed this Jul 28, 2026
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.

[BUG] can not add custom model of ollama

3 participants