Repository navigation
Go: add Markdown parser - #16016
Go: add Markdown parser#16016
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughAdds end-to-end markdown file ingestion support: a new ChangesMarkdown Ingestion Pipeline
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@internal/ingestion/parser/markdown_parser.go`:
- Line 47: Remove or gate behind explicit debug logging (off by default) the
stdout print statements in the markdown parser that expose user-provided content
and file metadata. Specifically, the fmt.Printf call that prints "Parsing
Markdown file" and similar stdout prints in the parser should be eliminated from
production code paths to prevent data leakage of user markdown content and file
metadata in runtime logs. If debug output is necessary for development purposes,
implement it using a debug logger that is disabled by default rather than direct
stdout printing.
In `@internal/utility/file.go`:
- Line 35: Update the FilenameType function (lines 103-112) to return
FileTypeMarkdown instead of FileTypeDOC when handling .md files, ensuring
consistent behavior with GetFileType which now correctly returns
FileTypeMarkdown for markdown files. Also review and align the related code at
lines 86-87 to ensure the classification is consistent across all utility
helpers.
🪄 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: 3b43912e-2f74-4982-a4bf-5537460a71d2
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (4)
go.modinternal/ingestion/parser/markdown_parser.gointernal/ingestion/parser/type.gointernal/utility/file.go
| } | ||
|
|
||
| func (p *MarkdownParser) Parse(filename string, data []byte) error { | ||
| fmt.Printf("Parsing Markdown file: %s\n", filename) |
There was a problem hiding this comment.
Do not print parsed document content/AST to stdout in parser path.
These stdout prints expose user-provided markdown content (via AST dump) and file metadata in runtime logs. This is a data leakage risk for ingestion workloads. Gate this behind explicit debug logging (off by default) or remove it from production code paths.
Also applies to: 63-65
🤖 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/markdown_parser.go` at line 47, Remove or gate
behind explicit debug logging (off by default) the stdout print statements in
the markdown parser that expose user-provided content and file metadata.
Specifically, the fmt.Printf call that prints "Parsing Markdown file" and
similar stdout prints in the parser should be eliminated from production code
paths to prevent data leakage of user markdown content and file metadata in
runtime logs. If debug output is necessary for development purposes, implement
it using a debug logger that is disabled by default rather than direct stdout
printing.
| FileTypePPTX FileType = "pptx" | ||
| FileTypeXLS FileType = "xls" | ||
| FileTypeXLSX FileType = "xlsx" | ||
| FileTypeMarkdown FileType = "md" |
There was a problem hiding this comment.
Align .md classification across utility helpers.
GetFileType now returns FileTypeMarkdown, but FilenameType still routes .md through FileTypeDOC (Line 103-112). This creates inconsistent parser routing depending on which helper a caller uses. Please update FilenameType so .md returns FileTypeMarkdown as well.
Also applies to: 86-87
🤖 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` at line 35, Update the FilenameType function (lines
103-112) to return FileTypeMarkdown instead of FileTypeDOC when handling .md
files, ensuring consistent behavior with GetFileType which now correctly returns
FileTypeMarkdown for markdown files. Also review and align the related code at
lines 86-87 to ensure the classification is consistent across all utility
helpers.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16016 +/- ##
=======================================
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. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Type of change