Skip to content

Custom the file extension when saving DB fields, and Parse HTML fragments not just full HTML doc - #15998

Merged
JinHai-CN merged 4 commits into
infiniflow:mainfrom
wadefelix:feat-db-column-file-extension
Sep 14, 2026
Merged

JinHai-CN merged 4 commits into
infiniflow:mainfrom
wadefelix:feat-db-column-file-extension

Conversation

@wadefelix

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR.

Since the database fields often store HTML fragments or Markdown fragments, a custom file name suffix field was added in the database datasource. Also, when parsing HTML, it should be compatible with parsing HTML fragments (without a body tag), not just full HTML documents (with a body tag).

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • [ √] New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3e323ce1-7754-47b6-a256-c84cf2ca1c88

📥 Commits

Reviewing files that changed from the base of the PR and between 6dd5d14 and 69058f4.

📒 Files selected for processing (2)
  • common/data_source/rdbms_connector.py
  • web/src/locales/en.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/locales/en.ts
  • common/data_source/rdbms_connector.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The RDBMS connector now supports a configurable file extension. Sync configuration passes the value to document generation. MySQL and PostgreSQL settings expose the option with .txt defaults and localized tips.

Changes

Configurable RDBMS file extension

Layer / File(s) Summary
RDBMS extension configuration and document wiring
common/data_source/rdbms_connector.py, rag/svr/sync_data_source.py
The connector accepts and stores file_extension, defaults it to .txt, uses it when creating documents, and receives it from sync configuration.
MySQL and PostgreSQL form configuration
web/src/pages/user-setting/data-source/constant/index.tsx, web/src/locales/en.ts
MySQL and PostgreSQL forms add optional config.file_extension fields with .txt placeholders and localized tips.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 69058

This change adds configurable RDBMS document file extensions with a .txt fallback and related interface text. No concrete merge-blocking risk is currently identified.

Suggested reviewers: mkaaad

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DataSourceForm
  participant SyncDataSource
  participant RDBMSConnector
  participant Document
  User->>DataSourceForm: Set file_extension
  DataSourceForm->>SyncDataSource: Save data source configuration
  SyncDataSource->>RDBMSConnector: Pass file_extension
  RDBMSConnector->>Document: Create document with configured extension
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the customizable database file extension and HTML fragment parsing changes. It is specific to the stated PR objectives, despite minor wording issues.
Description check ✅ Passed The description explains the problem, provides background, identifies the solution, and classifies the change as a new feature. It contains the required summary information, although the heading diffe…
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.

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

A rabbit taps the extension field
.txt rests softly, neatly sealed
Sync carries the chosen sign
Documents bloom with names in line
MySQL and Postgres hop along
Tips guide the settings with a song

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

@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: 2

Caution

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

⚠️ Outside diff range comments (1)
common/data_source/rdbms_connector.py (1)

56-85: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate and normalize file_extension before persisting it.

Line 84 accepts arbitrary config input and forwards it to Line 340 unchanged. Since the persisted schema stores extension-like fields with a 32-char limit, invalid/oversized values can break writes or downstream parser/type routing. Normalize (strip, ensure leading .) and validate (allowed charset + max length) once in the constructor.

Suggested fix
+import re
...
-        self.file_extension = file_extension if file_extension else '.txt'
+        self.file_extension = self._normalize_file_extension(file_extension)
...
+    `@staticmethod`
+    def _normalize_file_extension(file_extension: Any) -> str:
+        if file_extension is None:
+            return ".txt"
+        if not isinstance(file_extension, str):
+            raise ConnectorValidationError("file_extension must be a string.")
+
+        ext = file_extension.strip().lower()
+        if not ext:
+            return ".txt"
+        if not ext.startswith("."):
+            ext = f".{ext}"
+        if len(ext) > 32:
+            raise ConnectorValidationError("file_extension must be <= 32 characters.")
+        if not re.fullmatch(r"\.[a-z0-9]+", ext):
+            raise ConnectorValidationError(
+                "file_extension must contain only letters/numbers after '.'."
+            )
+        return ext

Also applies to: 340-340

🤖 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 `@common/data_source/rdbms_connector.py` around lines 56 - 85, The
file_extension parameter in the RDBMSConnector constructor is accepted without
validation or normalization, which can cause issues downstream since the
persisted schema has a 32-character limit on this field. In the __init__ method
where self.file_extension is set around line 84, add validation and
normalization logic: strip whitespace from the file_extension input, ensure it
has a leading dot, validate the character set is appropriate for file
extensions, and enforce a maximum length of 32 characters. If the input is
invalid or exceeds the limit, raise an appropriate exception with a descriptive
message. This ensures only valid, normalized extensions are persisted and
prevents downstream parser or type routing issues.
🤖 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 `@web/src/locales/en.ts`:
- Around line 1360-1361: The tooltip strings in the en.ts file are using title
case when they should follow the sentence case convention (first word
capitalized, rest lowercase). Update the mysqlFileExtensionTip entry to use
sentence case: change "The File Extension to save the Content column into files.
default: .txt" to "File extension to save the content column into files.
Default: .txt". Also apply the same sentence case correction to the similar
tooltip entry at lines 1374-1375 to ensure consistency with the en.ts coding
guidelines.

In `@web/src/pages/user-setting/data-source/constant/index.tsx`:
- Around line 1016-1023: Fix the spelling error in both field label definitions
in web/src/pages/user-setting/data-source/constant/index.tsx. At lines 1016-1023
in the MySQL field configuration object, change the label property from "File
Extenstion" to "File Extension". At lines 1098-1105 in the PostgreSQL field
configuration object, change the label property from "File Extenstion" to "File
Extension". Both occurrences use the same misspelled text in their label fields
and require the same correction.

---

Outside diff comments:
In `@common/data_source/rdbms_connector.py`:
- Around line 56-85: The file_extension parameter in the RDBMSConnector
constructor is accepted without validation or normalization, which can cause
issues downstream since the persisted schema has a 32-character limit on this
field. In the __init__ method where self.file_extension is set around line 84,
add validation and normalization logic: strip whitespace from the file_extension
input, ensure it has a leading dot, validate the character set is appropriate
for file extensions, and enforce a maximum length of 32 characters. If the input
is invalid or exceeds the limit, raise an appropriate exception with a
descriptive message. This ensures only valid, normalized extensions are
persisted and prevents downstream parser or type routing issues.
🪄 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: dadf011d-f152-4acf-86d2-287ab7b4ac54

📥 Commits

Reviewing files that changed from the base of the PR and between e89afba and 8821bf1.

📒 Files selected for processing (5)
  • common/data_source/rdbms_connector.py
  • deepdoc/parser/html_parser.py
  • rag/svr/sync_data_source.py
  • web/src/locales/en.ts
  • web/src/pages/user-setting/data-source/constant/index.tsx

Comment thread web/src/locales/en.ts Resolved
@wadefelix
wadefelix force-pushed the feat-db-column-file-extension branch 2 times, most recently from 2d50bc8 to 53c0428 Compare June 14, 2026 13:14
@JinHai-CN

Copy link
Copy Markdown
Member

@wadefelix would you please fix the conflicts?

@wadefelix
wadefelix force-pushed the feat-db-column-file-extension branch from 53c0428 to 9f6f65d Compare September 9, 2026 03:42
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@wadefelix
wadefelix force-pushed the feat-db-column-file-extension branch from 9f6f65d to 6dd5d14 Compare September 9, 2026 03:50
@wadefelix

Copy link
Copy Markdown
Contributor Author

@wadefelix would you please fix the conflicts?

done

@JinHai-CN
JinHai-CN requested a review from mkaaad September 9, 2026 04:49
@mkaaad mkaaad added the ci Continue Integration label Sep 9, 2026
mkaaad

This comment was marked as outdated.

@mkaaad
mkaaad self-requested a review September 9, 2026 07:22
Comment on lines +1634 to +1641
{
label: 'File Extension',
name: 'config.file_extension',
type: FormFieldType.Text,
required: false,
placeholder: '.txt',
tooltip: t('setting.postgresqlFileExtensionTip'),
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since each DB row is synced as a single file with a single extension,
while HTML/Markdown content usually lives in specific columns, the option only works correctly when users select only the pure HTML/Markdown columns in "content columns". Could you update the tooltip to make this clear? Proposed copy:
The extension used for documents synced from this source (default: .txt). Since each row is saved as one file, when set to .html or .md, select only content columns that are purely HTML or Markdown.
(applies to both mysqlFileExtensionTip and postgresqlFileExtensionTip)

@mkaaad

mkaaad commented Sep 9, 2026

Copy link
Copy Markdown
Member

And please fix the ruff formatting issue.

@JinHai-CN

Copy link
Copy Markdown
Member
╭──────────────────────────────────────────╮
│ 🥊 lefthook  v2.1.10   hook:  pre-commit │
╰──────────────────────────────────────────╯
│  gofmt (skip) no files for inspection
┃  ruff ❯ 
All checks passed!

┃  ruff-format ❯ 
Would reformat: common/data_source/rdbms_connector.py
1 file would be reformatted, 1 file already formatted

exit status 1

@wadefelix
wadefelix force-pushed the feat-db-column-file-extension branch from 69058f4 to 6eccac9 Compare September 9, 2026 12:35
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.83%. Comparing base (4c9768b) to head (ec17560).
⚠️ Report is 42 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15998      +/-   ##
==========================================
+ Coverage   29.85%   37.83%   +7.98%     
==========================================
  Files          54       54              
  Lines       15343    15354      +11     
  Branches      118      119       +1     
==========================================
+ Hits         4580     5809    +1229     
+ Misses      10751     9519    -1232     
- Partials       12       26      +14     

☔ 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.

@mkaaad mkaaad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@JinHai-CN
JinHai-CN merged commit c9a6f92 into infiniflow:main Sep 14, 2026
5 checks passed
JinHai-CN pushed a commit that referenced this pull request Sep 14, 2026
…9466)

Read file_extension from the connector config (default .txt) and use it
as the document extension instead of the hardcoded .txt when rows are
synced from MySQL and PostgreSQL data sources.
Python side: #15998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants