Skip to content

Fix: When creating a dataset, if no chunk_method is selected, there is no indication that this is a required field. - #14039

Merged
yingfeng merged 1 commit into
infiniflow:mainfrom
cike8899:fix-chunk-method-required
Apr 10, 2026
Merged

yingfeng merged 1 commit into
infiniflow:mainfrom
cike8899:fix-chunk-method-required

Conversation

@cike8899

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Fix: When creating a dataset, if no chunk_method is selected, there is no indication that this is a required field.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

… is no indication that this is a required field.
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 10, 2026
@cike8899 cike8899 added ci Continue Integration and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Apr 10, 2026
@cike8899
cike8899 marked this pull request as draft April 10, 2026 07:48
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A refactoring effort introduces a ParseType enum to replace magic numbers (1 and 2) for parse type handling across multiple components, hooks, forms, and utilities. The codebase transitions from numeric comparisons to enum-based constants, improving type safety. One dialog component is removed as part of this consolidation.

Changes

Cohort / File(s) Summary
Type Definition
web/src/constants/knowledge.ts
Added ParseType enum with BuiltIn = 1 and Pipeline = 2 members.
Localization
web/src/locales/en.ts, web/src/locales/zh.ts
Added dataFlowRequired translation strings for validation messaging.
Hooks & Type Exports
web/src/hooks/use-knowledge-request.ts, web/src/pages/dataset/dataset-setting/hooks.ts, web/src/pages/datasets/hooks.ts
Updated type signatures to use ParseType enum instead of number for parseType fields and simplified generic parameter syntax.
Form Schemas & Validation
web/src/pages/dataset/dataset-setting/form-schema.ts, web/src/pages/datasets/dataset-creating-dialog.tsx
Replaced z.number() with z.nativeEnum(ParseType) for validation; updated conditional logic to use enum comparisons instead of numeric literals.
Component Updates
web/src/components/chunk-method-dialog/index.tsx, web/src/components/data-pipeline-select/index.tsx, web/src/pages/dataset/dataset-setting/common-item.tsx
Replaced hardcoded numeric values with ParseType enum constants; added required attribute to form label.
Page Components
web/src/pages/dataset/dataset-setting/index.tsx, web/src/pages/dataset/dataset-setting/saving-button.tsx
Updated form initialization, conditional rendering, and validation checks to use ParseType.BuiltIn and ParseType.Pipeline instead of magic numbers.
Removed Module
web/src/pages/datasets/dataset-dataflow-creating-dialog.tsx
Deleted entire dialog component file containing InputForm and DatasetCreatingDialog exports (123 lines removed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

🧰 typescript, size:XL, refactor

Suggested reviewers

  • yingfeng
  • dcc123456

Poem

🐰 Magic numbers flee the warren,
Enums march in bright array!
Type-safe paths we now can follow,
Code grows cleaner every day.
No more guessing 1 or 2—
ParseType knows just what to do! 🎩✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main issue being fixed: missing required field indication for chunk_method during dataset creation.
Description check ✅ Passed The description addresses the problem statement and correctly identifies the change type, but lacks details on implementation approach and scope.

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


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

@cike8899
cike8899 marked this pull request as ready for review April 10, 2026 07:48
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 10, 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.

Caution

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

⚠️ Outside diff range comments (1)
web/src/components/data-pipeline-select/index.tsx (1)

83-90: ⚠️ Potential issue | 🟡 Minor

Required indicator is only applied in vertical mode.

Line 89 fixes the vertical layout, but the horizontal label still lacks the required marker, so the same UX gap can persist when layout === FormLayout.Horizontal.

Suggested fix
               <div className="flex gap-2 justify-between w-1/4">
                 <FormLabel
                   // tooltip={t('dataFlowTip')}
                   className="text-sm text-text-secondary whitespace-wrap "
+                  required
                 >
                   {t('manualSetup')}
                 </FormLabel>
               </div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/data-pipeline-select/index.tsx` around lines 83 - 90, The
FormLabel's required indicator is only set inside the FormLayout.Vertical branch
(layout === FormLayout.Vertical), leaving the FormLayout.Horizontal rendering
without the required marker; update the component so the required prop is
applied to the FormLabel regardless of layout—either move the required attribute
to the shared label rendering logic or add required to the FormLabel in the
FormLayout.Horizontal branch so both layouts show the required indicator
(references: layout, FormLayout.Vertical, FormLayout.Horizontal, FormLabel,
required).
🧹 Nitpick comments (4)
web/src/pages/dataset/dataset-setting/form-schema.ts (1)

16-16: Consider adding required validation for chunk_method when ParseType.BuiltIn is selected.

Given the PR objective is to indicate that chunk_method is required, consider adding a superRefine check similar to what's done in dataset-creating-dialog.tsx (lines 63-73) where chunk_method is validated as required when parseType === ParseType.BuiltIn.

Currently, chunk_method only has z.string() without a minimum length requirement or conditional validation.

💡 Suggested addition to superRefine
  .superRefine((data, ctx) => {
+   if (data.parse_type === ParseType.BuiltIn && !data.chunk_method?.trim()) {
+     ctx.addIssue({
+       path: ['chunk_method'],
+       message: t('common.pleaseSelect'),
+       code: 'custom',
+     });
+   }
    if (data.parse_type === ParseType.Pipeline && !data.pipeline_id) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/dataset/dataset-setting/form-schema.ts` at line 16, The schema
currently defines chunk_method as z.string() without enforcing it when
ParseType.BuiltIn is selected; update the form-schema's Zod schema to add a
superRefine (same pattern used in dataset-creating-dialog.tsx) that checks if
parseType === ParseType.BuiltIn and then verifies chunk_method is non-empty
(e.g., trim length > 0), returning a validation issue tied to the chunk_method
path when missing; reference the chunk_method field, the parseType value, and
implement the same conditional required validation as in
dataset-creating-dialog.tsx.
web/src/pages/dataset/dataset-setting/index.tsx (1)

130-130: Consider removing debug console.log.

This appears to be debug logging that could be cleaned up before merging.

🧹 Remove debug logging
-    console.log('🚀 ~ DatasetSettings ~ knowledgeDetails:', knowledgeDetails);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/dataset/dataset-setting/index.tsx` at line 130, Remove the
debug console.log in the DatasetSettings component that prints "🚀 ~
DatasetSettings ~ knowledgeDetails:" (the line referencing
knowledgeDetails)—either delete the console.log entirely or replace it with the
project's structured logger if persistent runtime visibility is required; ensure
no stray debug console statements remain in the DatasetSettings
function/component.
web/src/pages/datasets/dataset-creating-dialog.tsx (1)

114-116: Debug logging should use appropriate log level or be removed for production.

The error callback with console.warn is useful for development debugging but consider whether this should remain in production code. If kept, this is acceptable as it only logs validation errors during form submission failures.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/datasets/dataset-creating-dialog.tsx` around lines 114 - 116,
The inline console.warn in the form submission error handler should be removed
or replaced with a non-production logger: update the onSubmit prop where
form.handleSubmit(onSubmit, (errors) => { console.warn(errors); }) is used in
dataset-creating-dialog.tsx to either remove the error callback entirely or
replace console.warn with a debug-level logger (e.g., logger.debug or a
conditional that only logs in development via process.env.NODE_ENV ===
'development'), and ensure the validation errors are handled or surfaced to the
UI instead of leaving a console-only warning.
web/src/components/chunk-method-dialog/index.tsx (1)

31-31: Remove unused empty import.

This empty import statement serves no purpose and should be removed.

🧹 Remove empty import
-import {} from 'module';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/chunk-method-dialog/index.tsx` at line 31, Remove the
unused empty import statement "import {} from 'module';" from the file; locate
the line that imports an empty specifier and delete it so there are no no-op
imports remaining (ensure there are no other references to "module" that require
importing before removal).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@web/src/components/data-pipeline-select/index.tsx`:
- Around line 83-90: The FormLabel's required indicator is only set inside the
FormLayout.Vertical branch (layout === FormLayout.Vertical), leaving the
FormLayout.Horizontal rendering without the required marker; update the
component so the required prop is applied to the FormLabel regardless of
layout—either move the required attribute to the shared label rendering logic or
add required to the FormLabel in the FormLayout.Horizontal branch so both
layouts show the required indicator (references: layout, FormLayout.Vertical,
FormLayout.Horizontal, FormLabel, required).

---

Nitpick comments:
In `@web/src/components/chunk-method-dialog/index.tsx`:
- Line 31: Remove the unused empty import statement "import {} from 'module';"
from the file; locate the line that imports an empty specifier and delete it so
there are no no-op imports remaining (ensure there are no other references to
"module" that require importing before removal).

In `@web/src/pages/dataset/dataset-setting/form-schema.ts`:
- Line 16: The schema currently defines chunk_method as z.string() without
enforcing it when ParseType.BuiltIn is selected; update the form-schema's Zod
schema to add a superRefine (same pattern used in dataset-creating-dialog.tsx)
that checks if parseType === ParseType.BuiltIn and then verifies chunk_method is
non-empty (e.g., trim length > 0), returning a validation issue tied to the
chunk_method path when missing; reference the chunk_method field, the parseType
value, and implement the same conditional required validation as in
dataset-creating-dialog.tsx.

In `@web/src/pages/dataset/dataset-setting/index.tsx`:
- Line 130: Remove the debug console.log in the DatasetSettings component that
prints "🚀 ~ DatasetSettings ~ knowledgeDetails:" (the line referencing
knowledgeDetails)—either delete the console.log entirely or replace it with the
project's structured logger if persistent runtime visibility is required; ensure
no stray debug console statements remain in the DatasetSettings
function/component.

In `@web/src/pages/datasets/dataset-creating-dialog.tsx`:
- Around line 114-116: The inline console.warn in the form submission error
handler should be removed or replaced with a non-production logger: update the
onSubmit prop where form.handleSubmit(onSubmit, (errors) => {
console.warn(errors); }) is used in dataset-creating-dialog.tsx to either remove
the error callback entirely or replace console.warn with a debug-level logger
(e.g., logger.debug or a conditional that only logs in development via
process.env.NODE_ENV === 'development'), and ensure the validation errors are
handled or surfaced to the UI instead of leaving a console-only warning.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dec90f8d-b614-4635-bc31-88fa4a42946d

📥 Commits

Reviewing files that changed from the base of the PR and between 3d59448 and 4e98ea2.

📒 Files selected for processing (14)
  • web/src/components/chunk-method-dialog/index.tsx
  • web/src/components/data-pipeline-select/index.tsx
  • web/src/constants/knowledge.ts
  • web/src/hooks/use-knowledge-request.ts
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/dataset/dataset-setting/configuration/common-item.tsx
  • web/src/pages/dataset/dataset-setting/form-schema.ts
  • web/src/pages/dataset/dataset-setting/hooks.ts
  • web/src/pages/dataset/dataset-setting/index.tsx
  • web/src/pages/dataset/dataset-setting/saving-button.tsx
  • web/src/pages/datasets/dataset-creating-dialog.tsx
  • web/src/pages/datasets/dataset-dataflow-creating-dialog.tsx
  • web/src/pages/datasets/hooks.ts
💤 Files with no reviewable changes (1)
  • web/src/pages/datasets/dataset-dataflow-creating-dialog.tsx

@codecov

codecov Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (3d59448) to head (4e98ea2).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14039   +/-   ##
=======================================
  Coverage   96.66%   96.66%           
=======================================
  Files          10       10           
  Lines         690      690           
  Branches      108      108           
=======================================
  Hits          667      667           
  Misses          8        8           
  Partials       15       15           

☔ View full report in Codecov by Sentry.
📢 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.

@yingfeng
yingfeng merged commit 462be53 into infiniflow:main Apr 10, 2026
1 check passed
SailedApple1991 pushed a commit to SailedApple1991/greenlaw-ragflow that referenced this pull request Apr 12, 2026
… is no indication that this is a required field. (infiniflow#14039)

### What problem does this PR solve?
Fix: When creating a dataset, if no `chunk_method` is selected, there is
no indication that this is a required field.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
jasmingacic pushed a commit to jasmingacic/ragflow that referenced this pull request Apr 13, 2026
… is no indication that this is a required field. (infiniflow#14039)

### What problem does this PR solve?
Fix: When creating a dataset, if no `chunk_method` is selected, there is
no indication that this is a required field.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
jasmingacic pushed a commit to jasmingacic/ragflow that referenced this pull request Apr 23, 2026
… is no indication that this is a required field. (infiniflow#14039)

### What problem does this PR solve?
Fix: When creating a dataset, if no `chunk_method` is selected, there is
no indication that this is a required field.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
jasmingacic pushed a commit to jasmingacic/ragflow that referenced this pull request Apr 27, 2026
… is no indication that this is a required field. (infiniflow#14039)

### What problem does this PR solve?
Fix: When creating a dataset, if no `chunk_method` is selected, there is
no indication that this is a required field.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
JasleenKaurSethi pushed a commit to stackhpc/ragflow that referenced this pull request Apr 28, 2026
… is no indication that this is a required field. (infiniflow#14039)

### What problem does this PR solve?
Fix: When creating a dataset, if no `chunk_method` is selected, there is
no indication that this is a required field.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants