Tencent/WeKnora · error
unsupported simple format: %s
Error message
unsupported simple format: %s
What it means
The built-in converter only handles a fixed set of 'simple' formats (md, txt, csv, json, plus registered image and audio formats). Read returns this error for any other file type, signaling the caller should route the document to a full parser engine (e.g. anydoc) instead of the built-in simple converter.
Source
Thrown at internal/infrastructure/docparser/builtin_converter.go:78
return &types.ReadResult{MarkdownContent: string(req.FileContent)}, nil
case ft == "csv":
md, err := csvToMarkdown(req.FileContent)
if err != nil {
return nil, fmt.Errorf("csv conversion failed: %w", err)
}
return &types.ReadResult{MarkdownContent: md}, nil
case ft == "json":
md, err := jsonToMarkdown(req.FileContent)
if err != nil {
return nil, fmt.Errorf("json conversion failed: %w", err)
}
return &types.ReadResult{MarkdownContent: md}, nil
case imageFormats[ft]:
return imageToResult(req.FileName, req.FileContent), nil
case audioFormats[ft]:
return audioToResult(req.FileName, req.FileContent), nil
default:
return nil, fmt.Errorf("unsupported simple format: %s", ft)
}
}
// imageToResult wraps a standalone image as a markdown image reference with
// the raw bytes in ImageRefs, matching Python ImageParser behaviour.
func imageToResult(fileName string, data []byte) *types.ReadResult {
if fileName == "" {
fileName = "image.png"
}
refPath := "images/" + fileName
// Encode spaces so the markdown URL is valid and matches the regex in ResolveAndStore.
safeRef := strings.ReplaceAll(refPath, " ", "%20")
mime := http.DetectContentType(data)
return &types.ReadResult{
MarkdownContent: fmt.Sprintf("", fileName, safeRef),
ImageRefs: []types.ImageRef{
{View on GitHub (pinned to 988cbb0330)
Solutions
- Route unsupported types (docx/xlsx/pdf etc.) to the appropriate full parser engine via the engine registry instead of the builtin converter.
- Check the file extension/type detection — normalize case and confirm the extension matches actual content.
- Add the format to the builtin converter's supported maps only if a simple conversion genuinely exists.
- Reject or ask for a converted format (md/txt/csv/json) when no engine supports the type.
Example fix
// before result, err := builtinReader.Read(ctx, req) // req type = "docx" // after engine, err := registry.Select(req.FileType, tenant) result, err := engine.Read(ctx, req) // routes docx to full parser
Defensive patterns
Strategy: validation
Validate before calling
supported := map[string]bool{"md":true,"markdown":true,"txt":true,"text":true,"csv":true,"json":true}
if !supported[strings.ToLower(filepath.Ext(name))] {
// route to full parser engine instead of builtin converter
} Type guard
func builtinSupports(fileType string) bool {
switch strings.ToLower(fileType) {
case "md", "markdown", "txt", "text", "csv", "json": return true
}
return false
} Try / catch
res, err := reader.Read(ctx, req)
if err != nil && strings.Contains(err.Error(), "unsupported simple format") {
engine, selErr := registry.Select(req.FileType, tenant)
if selErr == nil { res, err = engine.Read(ctx, req) }
} Prevention
- Normalize file extensions (lowercase, trim) before type routing.
- Maintain a routing table mapping each file type to its correct engine.
- Don't send docx/xlsx/pdf/html to the builtin simple converter.
- When adding new formats, register them in the right engine, not the simple converter.
When it happens
Trigger: Calling the built-in converter's Read with a file whose detected type is not in its supported set — e.g. docx, xlsx, pptx, html, xml, pdf, zip — reaching the simple-format path.
Common situations: Routing logic that sends all uploads to the builtin engine; unknown/new extension not in the format map; file with wrong or missing extension; uppercase extensions not normalized before lookup.
Related errors
- file is not an executable script: %s
- parse document: %w
- anydoc scanned-PDF fallback returned no result for %q
- csv conversion failed: %w
- json conversion failed: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/3a69b04409bdedfd.
Report an issue: GitHub.