linshenkx/prompt-optimizer · warning · ImageError

UNSUPPORTED_TEST_TYPE

UNSUPPORTED_TEST_TYPE

Error message

UNSUPPORTED_TEST_TYPE

What it means

The Ollama image adapter's getTestImageRequest supports only its defined test types; any other testType throws UNSUPPORTED_TEST_TYPE with the value in metadata. Mirrors the same pattern as other adapters.

Source

Thrown at packages/core/src/services/image/adapters/ollama.ts:111

        .map((model: any) => (typeof model?.id === 'string' ? model.id.trim() : ''))
        .filter((id: string) => !!id)
        .map((id: string) => this.buildDefaultModel(id))
        .sort((a: ImageModel, b: ImageModel) => a.id.localeCompare(b.id))
    } catch (error) {
      console.warn('[OllamaImageAdapter] Failed to fetch models:', error)
      return []
    }
  }

  protected getTestImageRequest(testType: 'text2image' | 'image2image'): Omit<ImageRequest, 'configId'> {
    if (testType === 'text2image') {
      return {
        prompt: 'a simple red flower',
        count: 1
      }
    }

    throw new ImageError(IMAGE_ERROR_CODES.UNSUPPORTED_TEST_TYPE, undefined, { testType })
  }

  protected getParameterDefinitions(_modelId: string): readonly ImageParameterDefinition[] {
    // Keep this minimal; Ollama's OpenAI-compatible image API is experimental.
    return [
      {
        name: 'size',
        labelKey: 'image.params.size.label',
        descriptionKey: 'image.params.size.description',
        type: 'string',
        defaultValue: '1024x1024',
        allowedValues: ['1024x1024', '1536x1024', '1024x1536', 'auto']
      }
    ]
  }

  protected getDefaultParameterValues(_modelId: string): Record<string, unknown> {
    return { size: '1024x1024' }

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Use the supported text-to-image test type for Ollama models
  2. Gate test options by provider capability in the calling UI
  3. Contribute support if Ollama adds the capability
Defensive patterns

Strategy: validation

Validate before calling

const OLLAMA_TESTS = new Set(['text2image'])
if (provider === 'ollama' && !OLLAMA_TESTS.has(testType)) return skip()

Type guard

function ollamaSupportsTest(t: string): boolean { return t === 'text2image' }

Try / catch

if (!ollamaSupportsTest(testType)) return
await adapter.getTestImageRequest(testType)

Prevention

When it happens

Trigger: Running a model connectivity test with an unsupported testType against an Ollama-hosted image model — e.g. an edit or i2i test type, since Ollama's image API is text-to-image only.

Common situations: Generic test harnesses enumerating all test types; Ollama's experimental OpenAI-compatible image API lacking endpoints for the requested test kind.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/1b6fbf277f66341a. Report an issue: GitHub.