siyuan-note/siyuan · error

image prompt is required

Error message

image prompt is required

What it means

SiYuan's OpenAI image adapter refuses to call the image API when the request prompt is empty or whitespace-only. The prompt is the one required input for text-to-image models (DALL·E etc.), so the adapter fails fast with a clear message instead of sending a request the provider would reject. This is a client-side guard in OpenAIImageAdapter.Generate.

Solutions

  1. Ensure request.Prompt is set to a non-empty, non-whitespace string before calling Generate
  2. In the caller, check strings.TrimSpace(prompt) != "" and return a user-facing 'prompt required' message instead
  3. Fix the UI/client to disable the generate action until a prompt is entered

Example fix

// before
generated, err := adapter.Generate(ctx, GenerateImageRequest{Size: "1024x1024"})
// after
prompt := strings.TrimSpace(userPrompt)
if prompt == "" {
    return errors.New("please enter an image prompt")
}
generated, err := adapter.Generate(ctx, GenerateImageRequest{Prompt: prompt, Size: "1024x1024"})
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(prompt) == "" {
    return errors.New("image prompt is required")
}

Prevention

When it happens

Trigger: Calling Generate (directly or via the kernel AI image endpoint) with GenerateImageRequest.Prompt set to "", " ", or left unset after trimming.

Common situations: Frontend sends an empty prompt field; a pipeline passes a variable that was never populated; user submits the image dialog without typing a prompt; upstream text step produced an empty string that was passed through unchecked.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/b03f7677580db928. Report an issue: GitHub.

Appendix: source

Thrown at kernel/util/openai.go:882

		timeout = 30
	}
	client := NewOpenAIClientWithModel(apiKey, apiBaseURL, model, headers...)
	if isMiniMaxImageEndpoint(apiBaseURL) {
		config := openai.DefaultConfig(apiKey)
		config.BaseURL = apiBaseURL
		config.HTTPClient = &miniMaxImageTransport{base: newAIProviderHTTPClient(apiBaseURL, headers...)}
		client = openai.NewClientWithConfig(config)
	}
	return &OpenAIImageAdapter{
		client:  client,
		model:   model,
		timeout: time.Duration(timeout) * time.Second,
	}
}

func (adapter *OpenAIImageAdapter) Generate(ctx context.Context, request GenerateImageRequest) (GeneratedImage, error) {
	if strings.TrimSpace(request.Prompt) == "" {
		return GeneratedImage{}, errors.New("image prompt is required")
	}
	imageRequest := openai.ImageRequest{
		Prompt:  request.Prompt,
		Model:   adapter.model,
		N:       1,
		Size:    request.Size,
		Quality: request.Quality,
	}
	if strings.HasPrefix(strings.ToLower(adapter.model), "dall-e") {
		imageRequest.ResponseFormat = openai.CreateImageResponseFormatB64JSON
		if imageRequest.Quality == "auto" {
			imageRequest.Quality = ""
		}
	} else {
		imageRequest.OutputFormat = request.OutputFormat
	}
	requestCtx, cancel := context.WithTimeout(ctx, adapter.timeout)
	defer cancel()

View on GitHub (pinned to 9f775e8a12)