Skip to content

Fix Tag weight should be greater than 0 - #16657

Merged
wangq8 merged 5 commits into
infiniflow:mainfrom
wangq8:bugfix/fix-tag-weight-cannot-be-set-to-0
Jul 6, 2026
Merged

wangq8 merged 5 commits into
infiniflow:mainfrom
wangq8:bugfix/fix-tag-weight-cannot-be-set-to-0

Conversation

@wangq8

@wangq8 wangq8 commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

When edit chunk, add a tag, the default value is 0, it will clean all tags, the value is weight, it cannot be less than 0.

go version return 400 (default 500 when error) instead of 200
image

@wangq8 wangq8 added the ci Continue Integration label Jul 6, 2026
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Tag feature validation now requires positive finite scores in Python and Go. Chunk update errors now carry codes that the handler maps to HTTP 400 for validation-related failures. Both tag feature creation forms now use a minimum frequency of 1.

Changes

Tag feature validation and update flow

Layer / File(s) Summary
Python tag feature validation
common/tag_feature_utils.py
Numeric validation now rejects values ≤ 0 in addition to non-finite values, with an updated error message.
Go chunk validation helpers
internal/service/chunk/chunk.go, internal/service/chunk_types.go
UpdateChunk validates tag_feas before storing it, normalizes accepted numeric inputs to map[string]float64, and returns typed validation errors for invalid input.
Chunk handler coded error mapping
internal/handler/chunk.go, internal/handler/chunk_test.go
UpdateChunk maps coded validation-related errors to HTTP 400, and tests cover the coded-error path with an invalid tag_feas request.
Tag frequency inputs
web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx, web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx
Both chunk creation forms now clamp frequency at 1 and append new tag entries with frequency: 1.

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

Poem

I nibble on tags with a cheerful squeak,
Zero stayed home; one is the peak.
Bad scores now bounce with a hop and a thump,
The handler says "400" with a rabbity jump.
🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title matches the core change: tag weights are now required to be greater than 0.
Description check ✅ Passed The description includes the issue context and the intended behavior change, which fits the repo's required Summary section.

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.

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

🧹 Nitpick comments (1)
web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx (1)

1-138: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Consider consolidating duplicate TagFeatureItem component.

This component is identical to web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx. Since both copies were just edited in tandem for this fix, extracting a shared component would prevent future divergence (e.g., if this fix had only been applied to one file).

As per coding guidelines, "avoid duplicating component structures in JSX, and favor render props or reusable components."

🤖 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
`@web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx`
around lines 1 - 138, This TagFeatureItem implementation is duplicated in
another chunk-creating-modal path, so future changes can drift. Extract the
shared JSX and hooks logic from TagFeatureItem into a common reusable component
or render-prop-based helper, then have both pages import it instead of
maintaining two copies. Keep the current behavior in TagFeatureItem, but
centralize the duplicated SelectWithSearch/useFieldArray/form logic so edits
only happen in one place.

Source: Coding guidelines

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

Nitpick comments:
In
`@web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx`:
- Around line 1-138: This TagFeatureItem implementation is duplicated in another
chunk-creating-modal path, so future changes can drift. Extract the shared JSX
and hooks logic from TagFeatureItem into a common reusable component or
render-prop-based helper, then have both pages import it instead of maintaining
two copies. Keep the current behavior in TagFeatureItem, but centralize the
duplicated SelectWithSearch/useFieldArray/form logic so edits only happen in one
place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 589cf928-9fc2-4135-8a8c-4f0e71f50f11

📥 Commits

Reviewing files that changed from the base of the PR and between 98189cd and 4ed5081.

📒 Files selected for processing (5)
  • common/tag_feature_utils.py
  • internal/service/chunk/chunk.go
  • internal/service/chunk_types.go
  • web/src/pages/chunk/parsed-result/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/tag-feature-item.tsx
  • web/src/pages/dataflow-result/components/chunk-creating-modal/tag-feature-item.tsx

@codecov

codecov Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (98189cd) to head (48bf09e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16657   +/-   ##
=======================================
  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.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 6, 2026
@wangq8
wangq8 merged commit 57625c9 into infiniflow:main Jul 6, 2026
3 checks passed
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.

1 participant