Skip to content

Go: add office_oxide and parse docx file. - #15976

Merged
JinHai-CN merged 3 commits into
infiniflow:mainfrom
JinHai-CN:fix455
Jun 12, 2026
Merged

JinHai-CN merged 3 commits into
infiniflow:mainfrom
JinHai-CN:fix455

Conversation

@JinHai-CN

@JinHai-CN JinHai-CN commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

RAGFlow(api/default)> parse file 'test.docx';
Parsing DOCX file: test.docx
Document format: docx

Type of change

  • New Feature (non-breaking change which adds functionality)

Signed-off-by: Jin Hai <[email protected]>
Signed-off-by: Jin Hai <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a modular document parser framework that classifies files by type, instantiates format-specific parsers through a factory pattern, and integrates them into CLI local file parsing. It adds native library support for DOCX parsing via office_oxide and updates build configuration and documentation accordingly.

Changes

Document Parsing Framework

Layer / File(s) Summary
FileType enumeration and file classification
internal/utility/file.go
Introduces typed FileType enum with constants for PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, and media categories. Adds GetFileType(filename) to classify files by extension and updates FilenameType return type to use the new enum. Adjusts visual file detection in GetContentType to compare against typed constants.
FileParser interface and GetParser factory
internal/ingestion/parser/type.go
Defines FileParser interface with Parse and String methods. Implements GetParser(fileType) factory that switches on FileType to return the appropriate parser implementation (PPTX, PPT, XLSX, XLS, DOCX, DOC, PDF) or error for unsupported types.
Document parser implementations
internal/ingestion/parser/{doc,docx,pdf,ppt,pptx,xls,xlsx}_parser.go
Provides parser types for seven document formats. DOCXParser uses office_oxide library to extract and print document format, plain text, and Markdown representations. Other parsers are currently stubs that log filenames and return nil; DOCParser, PPTParser, PPTXParser, XLSParser, XLSXParser each implement Parse and String methods with placeholder logic.
CLI local file parsing integration
internal/cli/user_command.go
Refactors UserParseLocalFile to detect file type via utility.GetFileType, instantiate parser via parser.GetParser, read file content from disk, and invoke fileParser.Parse(filename, fileContent). Parse errors are wrapped using formatRequestError.
Native library build configuration
build.sh, go.mod
build.sh adds configurable OFFICE_OXIDE_PREFIX and OFFICE_OXIDE_VERSION globals, implements check_office_oxide_deps() to download and extract the correct OS/arch tarball from GitHub releases, verifies library and header presence, and calls the installer during build_go. Sets CGO_CFLAGS to include header path and CGO_LDFLAGS to link -loffice_oxide with rpath. go.mod adds direct dependencies: github.com/yfedoseev/office_oxide/go (v0.1.2) and github.com/yfedoseev/pdf_oxide/go (v0.3.63); indirect dependency: github.com/ebitengine/purego (v0.10.1).
Development guide updates
internal/development.md
Documents that the first build installs office_oxide native library. Adds note explaining that IDE and CLI builds must set CGO_CFLAGS and CGO_LDFLAGS environment variables to point to ~/.office_oxide include and lib paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

💞 feature, size:XXL

Poem

A warren of parsers, each with their call,
DOC and DOCX and PDF, handling them all,
With oxide libraries pulling the threads,
Files bloom in the system, from foot to their heads,
The framework expands, a rabbit's delight! 🐰📄

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. While it marks the type of change correctly, it only states 'As title' without providing substantive context about what problem is being solved. Expand the description to explain the problem being solved, why office_oxide is needed, what DOCX parsing enables, and any relevant implementation details or testing considerations.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding office_oxide native library support and DOCX file parsing capability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JinHai-CN JinHai-CN added the ci Continue Integration label Jun 12, 2026
@JinHai-CN
JinHai-CN marked this pull request as ready for review June 12, 2026 11:48
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/development.md (1)

10-20: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

The first-build command does not actually install office_oxide.

./build.sh --cpp only builds the C++ library. The new office_oxide install path runs inside build_go() in build.sh Lines 184-190, so this instruction currently sends readers down the wrong setup flow. Please change the first-build step to ./build.sh --all or explicitly document the required --cpp then --go sequence.

Suggested fix
-- First build (includes C++ dependencies and office_oxide native library):
+- First build (includes C++ dependencies and office_oxide native library):
 
 ```bash
-./build.sh --cpp
+./build.sh --all
  • Subsequent builds (Go only):
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @internal/development.md around lines 10 - 20, Update the documentation so
the "first build" command reflects the actual install flow: change the
first-step example from "./build.sh --cpp" to either "./build.sh --all" or
explicitly document running "./build.sh --cpp" followed by "./build.sh --go";
mention that the office_oxide install happens inside the build_go() step (so
--cpp alone does not install office_oxide) and ensure the examples and prose
consistently reference the script flags (--cpp, --go, --all) and the build_go()
install behavior.


</details>

<!-- cr-comment:v1:2950fbb6c740cbd224a3eea6 -->

</blockquote></details>

</blockquote></details>
🧹 Nitpick comments (1)
build.sh (1)

21-23: ⚡ Quick win

Keep the office_oxide version single-sourced.

OFFICE_OXIDE_VERSION here has to stay in lockstep with github.com/yfedoseev/office_oxide/go in go.mod Line 29. If one is bumped without the other, the build will fetch one native release and compile against a different Go wrapper version, which is a fragile ABI contract to enforce manually. Please derive this from one source or add a build-time consistency check.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build.sh` around lines 21 - 23, OFFICE_OXIDE_VERSION in build.sh must be
single-sourced with the module version in go.mod
(github.com/yfedoseev/office_oxide/go) to avoid ABI mismatches; update build.sh
to derive the native release version from go.mod (parse the module dependency
entry for github.com/yfedoseev/office_oxide/go) or add a build-time consistency
check that reads go.mod, extracts the office_oxide version and compares it to
OFFICE_OXIDE_VERSION (failing the build on mismatch); refer to the
OFFICE_OXIDE_VERSION variable in build.sh and the go.mod dependency entry for
github.com/yfedoseev/office_oxide/go when implementing this.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build.sh`:
- Around line 122-131: The install success check only verifies lib_path; add a
second existence check for the header at
"${OFFICE_OXIDE_PREFIX}/include/office_oxide_c/office_oxide.h" (or a new
variable header_path) right after the lib_path check and, if missing, echo an
error with the missing header path and exit 1; ensure you create a clear message
and suggest the same curl/tar extraction hint used for lib_path so the script
fails fast and reports the actionable missing header instead of letting `go
build` fail later.

In `@internal/cli/user_command.go`:
- Around line 3261-3264: The error message for the os.ReadFile failure is
misleading: update the fmt.Errorf call that currently uses "failed to read dsl
file" so it reflects the actual user-selected input document (use filename or a
phrase like "input file" / "user-selected document") and include the filename
and wrapped error (the os.ReadFile call and variable filename identify the spot
to change).

In `@internal/ingestion/parser/doc_parser.go`:
- Around line 28-30: The placeholder parsers (e.g., DOCParser.Parse,
PDFParser.Parse, PPTParser.Parse, XLSParser.Parse, XLSXParser.Parse) currently
ignore the input data and return nil, making unsupported formats appear
successful; update each Parse method to either implement actual extraction or
explicitly return a not-implemented error (e.g., errors.New("parser not
implemented for <format>")) so UserParseLocalFile won't treat a no-op as
success—locate the Parse methods in the respective types (DOCParser.Parse,
PDFParser.Parse, PPTParser.Parse, XLSParser.Parse, XLSXParser.Parse) and replace
the println+nil with either working extraction logic or a clear error return.

In `@internal/ingestion/parser/docx_parser.go`:
- Around line 19-23: The DOCX parser imports cgo-only office_oxide
unconditionally; add build tags to isolate it: mark the existing DOCX
implementation file (containing NewDOCXParser and any direct use of officeOxide)
with a "//go:build cgo" tag and create a companion stub file with "//go:build
!cgo" that provides a fallback NewDOCXParser (or returns an
error/not-implemented) so the package builds without CGO; also ensure the
factory wiring in internal/ingestion/parser/type.go checks the returned
value/error from NewDOCXParser (or gates registration) so non-cgo builds don’t
register a non-functional DOCX parser.

In `@internal/ingestion/parser/pptx_parser.go`:
- Around line 28-30: PPTXParser.Parse currently ignores the input and returns
nil; stop silently succeeding by returning a clear not-implemented error from
PPTXParser.Parse (e.g., return fmt.Errorf("PPTX parsing not implemented")) so
callers fail fast, or alternatively remove FileTypePPTX from the parser registry
in GetParser until real parsing is implemented; update any tests/usage
accordingly to expect the error instead of a successful parse.

In `@internal/utility/file.go`:
- Around line 60-87: Update GetFileType to keep the explicit Office and PDF
cases but for any unrecognized suffix call and return the broader classification
from FilenameType(filename) instead of returning FileTypeOTHER; locate the
switch in GetFileType and replace the default branch (and possibly other
non-office branches) so that when suffix isn't one of
"pdf","xls","xlsx","doc","docx","ppt","pptx" it delegates to FilenameType to
preserve classifications like txt, md, json, csv, jpg, png, mp3, etc.

---

Outside diff comments:
In `@internal/development.md`:
- Around line 10-20: Update the documentation so the "first build" command
reflects the actual install flow: change the first-step example from "./build.sh
--cpp" to either "./build.sh --all" or explicitly document running "./build.sh
--cpp" followed by "./build.sh --go"; mention that the office_oxide install
happens inside the build_go() step (so --cpp alone does not install
office_oxide) and ensure the examples and prose consistently reference the
script flags (--cpp, --go, --all) and the build_go() install behavior.

---

Nitpick comments:
In `@build.sh`:
- Around line 21-23: OFFICE_OXIDE_VERSION in build.sh must be single-sourced
with the module version in go.mod (github.com/yfedoseev/office_oxide/go) to
avoid ABI mismatches; update build.sh to derive the native release version from
go.mod (parse the module dependency entry for
github.com/yfedoseev/office_oxide/go) or add a build-time consistency check that
reads go.mod, extracts the office_oxide version and compares it to
OFFICE_OXIDE_VERSION (failing the build on mismatch); refer to the
OFFICE_OXIDE_VERSION variable in build.sh and the go.mod dependency entry for
github.com/yfedoseev/office_oxide/go when implementing this.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc614c5c-a9a8-4724-97f3-38a935a2bd69

📥 Commits

Reviewing files that changed from the base of the PR and between 4115282 and d67c354.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (14)
  • build.sh
  • go.mod
  • internal/cli/user_command.go
  • internal/development.md
  • internal/ingestion/parser/doc_parser.go
  • internal/ingestion/parser/docx_parser.go
  • internal/ingestion/parser/pdf_parser.go
  • internal/ingestion/parser/ppt_parser.go
  • internal/ingestion/parser/pptx_parser.go
  • internal/ingestion/parser/type.go
  • internal/ingestion/parser/xls_parser.go
  • internal/ingestion/parser/xlsx_parser.go
  • internal/service/file.go
  • internal/utility/file.go

Comment thread build.sh
Comment on lines +122 to +131
mkdir -p "${OFFICE_OXIDE_PREFIX}"
_download_and_extract "$release_url" "${OFFICE_OXIDE_PREFIX}"

if [ ! -f "$lib_path" ]; then
echo -e "${RED}Error: Failed to install office_oxide native library (missing ${lib_path})${NC}"
echo " Try: curl -fsSL ${release_url} | tar xzf - -C ${OFFICE_OXIDE_PREFIX}"
exit 1
fi

echo -e "${GREEN}✓ office_oxide native library installed${NC}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail the install when the header is missing too.

The success path only validates ${OFFICE_OXIDE_PREFIX}/lib/${lib_file}, but the next step also requires ${OFFICE_OXIDE_PREFIX}/include/office_oxide_c/office_oxide.h on Line 188. A partial extract currently reports a successful install and then fails later in go build with a less actionable CGO error.

Suggested fix
-    if [ ! -f "$lib_path" ]; then
-        echo -e "${RED}Error: Failed to install office_oxide native library (missing ${lib_path})${NC}"
-        echo "  Try: curl -fsSL ${release_url} | tar xzf - -C ${OFFICE_OXIDE_PREFIX}"
+    if [ ! -f "$lib_path" ] || [ ! -f "$header_path" ]; then
+        echo -e "${RED}Error: Failed to install office_oxide native library${NC}"
+        echo "  Missing library: ${lib_path}"
+        echo "  Missing header:  ${header_path}"
+        echo "  Try: curl -fsSL ${release_url} | tar xzf - -C ${OFFICE_OXIDE_PREFIX}"
         exit 1
     fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mkdir -p "${OFFICE_OXIDE_PREFIX}"
_download_and_extract "$release_url" "${OFFICE_OXIDE_PREFIX}"
if [ ! -f "$lib_path" ]; then
echo -e "${RED}Error: Failed to install office_oxide native library (missing ${lib_path})${NC}"
echo " Try: curl -fsSL ${release_url} | tar xzf - -C ${OFFICE_OXIDE_PREFIX}"
exit 1
fi
echo -e "${GREEN}✓ office_oxide native library installed${NC}"
mkdir -p "${OFFICE_OXIDE_PREFIX}"
_download_and_extract "$release_url" "${OFFICE_OXIDE_PREFIX}"
if [ ! -f "$lib_path" ] || [ ! -f "$header_path" ]; then
echo -e "${RED}Error: Failed to install office_oxide native library${NC}"
echo " Missing library: ${lib_path}"
echo " Missing header: ${header_path}"
echo " Try: curl -fsSL ${release_url} | tar xzf - -C ${OFFICE_OXIDE_PREFIX}"
exit 1
fi
echo -e "${GREEN}✓ office_oxide native library installed${NC}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build.sh` around lines 122 - 131, The install success check only verifies
lib_path; add a second existence check for the header at
"${OFFICE_OXIDE_PREFIX}/include/office_oxide_c/office_oxide.h" (or a new
variable header_path) right after the lib_path check and, if missing, echo an
error with the missing header path and exit 1; ensure you create a clear message
and suggest the same curl/tar extraction hint used for lib_path so the script
fails fast and reports the actionable missing header instead of letting `go
build` fail later.

Comment on lines +3261 to +3264
fileContent, err := os.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed to read dsl file: %w", err)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix the misleading file-read error text.

Line 3263 says "failed to read dsl file" even though this branch reads the user-selected input document. When local parsing fails on a missing DOCX/PDF/etc, the CLI will point users at the wrong file.

Suggested fix
 	fileContent, err := os.ReadFile(filename)
 	if err != nil {
-		return nil, fmt.Errorf("failed to read dsl file: %w", err)
+		return nil, fmt.Errorf("failed to read file: %w", err)
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fileContent, err := os.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed to read dsl file: %w", err)
}
fileContent, err := os.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed to read file: %w", err)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/user_command.go` around lines 3261 - 3264, The error message for
the os.ReadFile failure is misleading: update the fmt.Errorf call that currently
uses "failed to read dsl file" so it reflects the actual user-selected input
document (use filename or a phrase like "input file" / "user-selected document")
and include the filename and wrapped error (the os.ReadFile call and variable
filename identify the spot to change).

Comment on lines +28 to +30
func (p *DOCParser) Parse(filename string, data []byte) error {
fmt.Printf("Parsing DOC file: %s\n", filename)
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Placeholder parsers are registered as supported but never parse anything.

DOCParser in internal/ingestion/parser/doc_parser.go, PDFParser in internal/ingestion/parser/pdf_parser.go, PPTParser in internal/ingestion/parser/ppt_parser.go, XLSParser in internal/ingestion/parser/xls_parser.go, and XLSXParser in internal/ingestion/parser/xlsx_parser.go all ignore data and return nil. Because UserParseLocalFile treats nil as success, these formats now look fully supported even though the command only logs a filename. Either implement extraction before wiring them in, or return a clear "not implemented" error until they are real.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/parser/doc_parser.go` around lines 28 - 30, The
placeholder parsers (e.g., DOCParser.Parse, PDFParser.Parse, PPTParser.Parse,
XLSParser.Parse, XLSXParser.Parse) currently ignore the input data and return
nil, making unsupported formats appear successful; update each Parse method to
either implement actual extraction or explicitly return a not-implemented error
(e.g., errors.New("parser not implemented for <format>")) so UserParseLocalFile
won't treat a no-op as success—locate the Parse methods in the respective types
(DOCParser.Parse, PDFParser.Parse, PPTParser.Parse, XLSParser.Parse,
XLSXParser.Parse) and replace the println+nil with either working extraction
logic or a clear error return.

Comment on lines +19 to +23
import (
"fmt"

officeOxide "github.com/yfedoseev/office_oxide/go"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

fd -a 'docx_parser.go|type.go|go.mod|build.sh'
echo
rg -n --glob 'go.mod' --glob 'build.sh' --glob 'internal/**/*.go' \
  'office_oxide|//go:build|CGO_CFLAGS|CGO_LDFLAGS|NewDOCXParser|FileTypeDOCX'

Repository: infiniflow/ragflow

Length of output: 2937


Isolate office_oxide behind a build tag (or add a !cgo DOCX fallback)
internal/ingestion/parser/docx_parser.go unconditionally imports github.com/yfedoseev/office_oxide/go, and internal/ingestion/parser/type.go wires utility.FileTypeDOCX to NewDOCXParser(), making the parser package’s build depend on native/CGO office_oxide even if DOCX parsing isn’t used. build.sh sets up native office_oxide + CGO flags, but there are no //go:build guards around the DOCX implementation.
Add //go:build cgo to the DOCX parser and a //go:build !cgo stub/fallback (and/or factory gating) so non-CGO environments still compile.

🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 22-22: could not import github.com/yfedoseev/office_oxide/go (-: build constraints exclude all Go files in /home/jailuser/.cache/go/.go-mod-cache/github.com/yfedoseev/office_oxide/[email protected])

(typecheck)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/parser/docx_parser.go` around lines 19 - 23, The DOCX
parser imports cgo-only office_oxide unconditionally; add build tags to isolate
it: mark the existing DOCX implementation file (containing NewDOCXParser and any
direct use of officeOxide) with a "//go:build cgo" tag and create a companion
stub file with "//go:build !cgo" that provides a fallback NewDOCXParser (or
returns an error/not-implemented) so the package builds without CGO; also ensure
the factory wiring in internal/ingestion/parser/type.go checks the returned
value/error from NewDOCXParser (or gates registration) so non-cgo builds don’t
register a non-functional DOCX parser.

Source: Linters/SAST tools

Comment on lines +28 to +30
func (p *PPTXParser) Parse(filename string, data []byte) error {
fmt.Printf("Parsing PPTX file: %s\n", filename)
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail fast until PPTX parsing is actually implemented.

Parse ignores data, only logs the filename, and returns nil. In the CLI flow that means every .pptx file is reported as successfully parsed even though nothing was extracted.

If the implementation is still a placeholder, return an error here (or stop registering FileTypePPTX in GetParser) instead of silently succeeding.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/parser/pptx_parser.go` around lines 28 - 30,
PPTXParser.Parse currently ignores the input and returns nil; stop silently
succeeding by returning a clear not-implemented error from PPTXParser.Parse
(e.g., return fmt.Errorf("PPTX parsing not implemented")) so callers fail fast,
or alternatively remove FileTypePPTX from the parser registry in GetParser until
real parsing is implemented; update any tests/usage accordingly to expect the
error instead of a successful parse.

Comment thread internal/utility/file.go
Comment on lines +60 to +87
func GetFileType(filename string) FileType {

ext := filepath.Ext(filename)
var suffix string
if len(ext) > 0 && ext[0] == '.' {
suffix = strings.ToLower(ext[1:])
} else {
suffix = strings.ToLower(ext)
}

switch suffix {
case "pdf":
return FileTypePDF
case "xls":
return FileTypeXLS
case "xlsx":
return FileTypeXLSX
case "doc":
return FileTypeDOC
case "docx":
return FileTypeDOCX
case "ppt":
return FileTypePPT
case "pptx":
return FileTypePPTX
default:
return FileTypeOTHER
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Preserve the existing non-Office classifications in GetFileType.

UserParseLocalFile now drives parser selection through GetFileType(...), but this switch only recognizes PDF and the Office extensions. Extensions that FilenameType(...) still treats as parseable/document-like (txt, md, json, csv, etc.) or media (jpg, png, mp3, ...) now collapse to other, so the CLI rejects them before parsing starts.

Please keep the new specific Office mappings, but fall back to the broader FilenameType(...) classification for everything else.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/utility/file.go` around lines 60 - 87, Update GetFileType to keep
the explicit Office and PDF cases but for any unrecognized suffix call and
return the broader classification from FilenameType(filename) instead of
returning FileTypeOTHER; locate the switch in GetFileType and replace the
default branch (and possibly other non-office branches) so that when suffix
isn't one of "pdf","xls","xlsx","doc","docx","ppt","pptx" it delegates to
FilenameType to preserve classifications like txt, md, json, csv, jpg, png, mp3,
etc.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (4115282) to head (d67c354).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15976   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant