linshenkx/prompt-optimizer · warning · ImageError

UNSUPPORTED_TEST_TYPE

UNSUPPORTED_TEST_TYPE

Error message

UNSUPPORTED_TEST_TYPE

What it means

The OpenAI image adapter's getTestImageRequest supports specific test types; any other testType throws UNSUPPORTED_TEST_TYPE with the offending value in metadata, following the shared adapter pattern.

Source

Thrown at packages/core/src/services/image/adapters/openai.ts:157

    if (testType === 'text2image') {
      return {
        prompt: 'a simple red flower',
        count: 1
      }
    }

    if (testType === 'image2image') {
      return {
        prompt: 'make this image more colorful',
        inputImage: {
          b64: AbstractImageProviderAdapter.TEST_IMAGE_BASE64.split(',')[1], // 去除data URL前缀
          mimeType: 'image/png'
        },
        count: 1
      }
    }

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

  protected getParameterDefinitions(_modelId: string): readonly ImageParameterDefinition[] {
    // GPT Image 2 使用统一的参数定义,n参数固定为1不暴露给用户
    return [
      {
        name: 'size',
        labelKey: 'image.params.size.label',
        descriptionKey: 'image.params.size.description',
        type: 'string',
        defaultValue: '1024x1024',
        allowedValues: [...GPT_IMAGE_2_SIZE_VALUES]
      },
      {
        name: 'quality',
        labelKey: 'image.params.quality.label',
        descriptionKey: 'image.params.quality.description',
        type: 'string',

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Use the supported test types for OpenAI image models
  2. Filter test options by adapter capability before invoking
  3. Implement the missing test type in the adapter if genuinely needed
Defensive patterns

Strategy: validation

Validate before calling

const OPENAI_TESTS = new Set(['text2image' /* supported types */])
if (!OPENAI_TESTS.has(testType)) skip()

Type guard

function openaiSupportsTest(t: string): boolean { return OPENAI_TESTS.has(t) }

Try / catch

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

Prevention

When it happens

Trigger: Requesting a test image request type the OpenAI adapter doesn't implement — e.g. a test type for a capability GPT Image models don't expose or one added generically by the test harness.

Common situations: Test-runner enumerations passing unsupported types to every adapter; new test types introduced for other providers without an OpenAI implementation.

Related errors


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