{"record":{"id":"3a69b04409bdedfd","repo":"Tencent/WeKnora","slug":"unsupported-simple-format-s","errorCode":null,"errorMessage":"unsupported simple format: %s","messagePattern":"unsupported simple format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/builtin_converter.go","lineNumber":78,"sourceCode":"\t\treturn &types.ReadResult{MarkdownContent: string(req.FileContent)}, nil\n\tcase ft == \"csv\":\n\t\tmd, err := csvToMarkdown(req.FileContent)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"csv conversion failed: %w\", err)\n\t\t}\n\t\treturn &types.ReadResult{MarkdownContent: md}, nil\n\tcase ft == \"json\":\n\t\tmd, err := jsonToMarkdown(req.FileContent)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"json conversion failed: %w\", err)\n\t\t}\n\t\treturn &types.ReadResult{MarkdownContent: md}, nil\n\tcase imageFormats[ft]:\n\t\treturn imageToResult(req.FileName, req.FileContent), nil\n\tcase audioFormats[ft]:\n\t\treturn audioToResult(req.FileName, req.FileContent), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported simple format: %s\", ft)\n\t}\n}\n\n// imageToResult wraps a standalone image as a markdown image reference with\n// the raw bytes in ImageRefs, matching Python ImageParser behaviour.\nfunc imageToResult(fileName string, data []byte) *types.ReadResult {\n\tif fileName == \"\" {\n\t\tfileName = \"image.png\"\n\t}\n\trefPath := \"images/\" + fileName\n\t// Encode spaces so the markdown URL is valid and matches the regex in ResolveAndStore.\n\tsafeRef := strings.ReplaceAll(refPath, \" \", \"%20\")\n\tmime := http.DetectContentType(data)\n\n\treturn &types.ReadResult{\n\t\tMarkdownContent: fmt.Sprintf(\"![%s](%s)\", fileName, safeRef),\n\t\tImageRefs: []types.ImageRef{\n\t\t\t{","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/builtin_converter.go#L60-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nresult, err := builtinReader.Read(ctx, req) // req type = \"docx\"\n// after\nengine, err := registry.Select(req.FileType, tenant)\nresult, err := engine.Read(ctx, req) // routes docx to full parser","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"md\":true,\"markdown\":true,\"txt\":true,\"text\":true,\"csv\":true,\"json\":true}\nif !supported[strings.ToLower(filepath.Ext(name))] {\n    // route to full parser engine instead of builtin converter\n}","typeGuard":"func builtinSupports(fileType string) bool {\n    switch strings.ToLower(fileType) {\n    case \"md\", \"markdown\", \"txt\", \"text\", \"csv\", \"json\": return true\n    }\n    return false\n}","tryCatchPattern":"res, err := reader.Read(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"unsupported simple format\") {\n    engine, selErr := registry.Select(req.FileType, tenant)\n    if selErr == nil { res, err = engine.Read(ctx, req) }\n}","preventionTips":["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."],"tags":["docparser","unsupported-format","file-type","routing"],"backgroundTag":"unsupported-file-format","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}