Skip to content

Fix metadata config - #14480

Merged
yingfeng merged 3 commits into
infiniflow:mainfrom
wangq8:bugfix/fix-metadata-config
Apr 29, 2026
Merged

yingfeng merged 3 commits into
infiniflow:mainfrom
wangq8:bugfix/fix-metadata-config

Conversation

@wangq8

@wangq8 wangq8 commented Apr 29, 2026 •

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Fix metadata config

Type of change

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

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 367d31b6-0b49-4df2-b26e-06250ddbda0a

📥 Commits

Reviewing files that changed from the base of the PR and between e387646 and d5c761d.

📒 Files selected for processing (1)
  • test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_retrieval.py

📝 Walkthrough

Walkthrough

Restructures auto-metadata: per-field id renamed name→key, type accepts "number", examples/restrict_values replaced by enum; top-level fields + enabled replaced by metadata and built_in_metadata lists. API now reads/writes those arrays directly and frontend includes type in payloads.

Changes

Cohort / File(s) Summary
Validation Schema
api/utils/validation_utils.py
Renamed per-field identifier (name → key), added "number" to type enum, removed examples/restrict_values, added enum; replaced enabled+fields with metadata and built_in_metadata lists.
API Service
api/apps/services/dataset_api_service.py
get_auto_metadata and update_auto_metadata stop normalizing/serializing {enabled, fields} and instead return/copy parser_config's metadata and built_in_metadata arrays directly.
Frontend Hook
web/src/pages/dataset/components/metedata/hooks/use-manage-modal.ts
Metadata settings JSON now includes a type property derived from each row's valueType (lowercased).
Tests
test/testcases/test_sdk_api/test_dataset_mangement/test_auto_metadata.py, test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_retrieval.py
Removed SDK auto-metadata test file; updated HTTP API test payload to use metadata with key fields instead of fields/name and removed enabled.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Frontend as "Frontend\n(use-manage-modal)"
  participant API as "Dataset API\n(dataset_api_service)"
  participant Store as "Parser Config\n(storage)"

  Client->>Frontend: open/manage metadata UI
  Frontend->>Client: show current metadata (metadata + built_in_metadata)
  Client->>Frontend: submit metadata changes (metadata + built_in_metadata, include type)
  Frontend->>API: POST/PUT /metadata/config with payload
  API->>Store: write parser_config.metadata & parser_config.built_in_metadata
  Store-->>API: ack
  API-->>Frontend: 200 OK with saved arrays
  Frontend-->>Client: show success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

🐞 bug, size:S

Suggested reviewers

  • dcc123456
  • yingfeng
  • yuzhichang
  • JinHai-CN

Poem

🐰 Keys hop in, names hop out with glee,
Enums and numbers twirl in metadata tree,
Two lists now sing where one once lay,
Parsers store truth clear as day,
A happy rabbit cheers — data set free! 🎶

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and lacks meaningful detail about what problem is being solved and the specific changes being made. Expand the description to explain the specific issue, the schema changes (e.g., field renaming, array restructuring), and why these changes fix the bug.
Title check ❓ Inconclusive The title 'Fix metadata config' is vague and lacks specificity about the actual changes made to the metadata configuration system. Consider a more specific title that describes the key change, such as 'Restructure metadata config schema to use metadata and built_in_metadata arrays' or 'Update metadata config to remove enabled flag and rename field identifier'.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@wangq8
wangq8 force-pushed the bugfix/fix-metadata-config branch from 266043b to df7e253 Compare April 29, 2026 09:53
@wangq8 wangq8 added the ci Continue Integration label Apr 29, 2026
@wangq8
wangq8 marked this pull request as ready for review April 29, 2026 09:58
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 29, 2026
@wangq8
wangq8 requested a review from euvre April 29, 2026 10:00

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

Caution

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

⚠️ Outside diff range comments (1)
web/src/pages/dataset/components/metedata/hooks/use-manage-modal.ts (1)

98-106: ⚠️ Potential issue | 🟠 Major

Potential API validation failure when valueType is undefined.

The optional chaining item.valueType?.toLowerCase() can produce undefined when valueType is not set. However, the backend AutoMetadataField.type (in validation_utils.py:374) is a required field expecting Literal["string", "list", "time", "number"].

When valueType is undefined, the payload will include type: undefined (omitted in JSON serialization), causing the backend to reject the request with a validation error.

🐛 Proposed fix: default to a valid type when valueType is undefined
   tableDataToMetaDataSettingJSON(
     data: IMetaDataTableData[],
   ): IMetaDataReturnJSONSettings {
     return data.map((item) => {
       return {
         key: item.field,
-        type: item.valueType?.toLowerCase(),
+        type: (item.valueType ?? DEFAULT_VALUE_TYPE).toLowerCase(),
         description: item.description,
         enum: item.values,
       };
     });
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/dataset/components/metedata/hooks/use-manage-modal.ts` around
lines 98 - 106, The map that builds the metadata payload in use-manage-modal.ts
currently uses item.valueType?.toLowerCase() which can yield undefined and
trigger backend validation (AutoMetadataField.type) failures; update the mapping
in the function that returns { key, type, description, enum } to coerce
valueType safely (e.g., (item.valueType || 'string').toLowerCase()) or otherwise
default to a valid literal from ["string","list","time","number"] so the
produced type is never undefined before sending to the backend.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/utils/validation_utils.py`:
- Around line 370-384: The create_dataset and update_dataset handlers still
parse the old auto-metadata shape; update the logic in functions create_dataset
and update_dataset to accept the new AutoMetadataConfig/AutoMetadataField schema
by reading auto_meta.get("metadata", []) and auto_meta.get("built_in_metadata",
[]) (merge or handle separately as before), replace any uses of f.get("name",
"") with f.get("key", ""), replace f.get("examples") with f.get("enum"), and
stop expecting f.get("restrict_values", ...) and auto_meta.get("enabled", ...)
(treat missing flags as default behavior or drop them); ensure you handle
None/missing keys gracefully (default to empty lists) when building the internal
metadata representation so dataset creation/update continues to work with the
new schema.

---

Outside diff comments:
In `@web/src/pages/dataset/components/metedata/hooks/use-manage-modal.ts`:
- Around line 98-106: The map that builds the metadata payload in
use-manage-modal.ts currently uses item.valueType?.toLowerCase() which can yield
undefined and trigger backend validation (AutoMetadataField.type) failures;
update the mapping in the function that returns { key, type, description, enum }
to coerce valueType safely (e.g., (item.valueType || 'string').toLowerCase()) or
otherwise default to a valid literal from ["string","list","time","number"] so
the produced type is never undefined before sending to the backend.
🪄 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: af6a4c6f-7f24-4de1-809c-3e88b167e5cd

📥 Commits

Reviewing files that changed from the base of the PR and between 3991bdf and df7e253.

📒 Files selected for processing (3)
  • api/apps/services/dataset_api_service.py
  • api/utils/validation_utils.py
  • web/src/pages/dataset/components/metedata/hooks/use-manage-modal.ts

Comment thread api/utils/validation_utils.py Resolved
@codecov

codecov Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.16%. Comparing base (3991bdf) to head (d5c761d).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14480      +/-   ##
==========================================
- Coverage   95.30%   94.16%   -1.14%     
==========================================
  Files          10       10              
  Lines         703      703              
  Branches      112      112              
==========================================
- Hits          670      662       -8     
- Misses         16       25       +9     
+ Partials       17       16       -1     

☔ 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 5018459 into infiniflow:main Apr 29, 2026
1 check passed
@dosubot dosubot Bot mentioned this pull request Apr 29, 2026
4 tasks done
TIMBLOCKER pushed a commit to TIMBLOCKER/kira that referenced this pull request Apr 29, 2026
### What problem does this PR solve?

Fix metadata config

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
TIMBLOCKER pushed a commit to TIMBLOCKER/kira that referenced this pull request May 7, 2026
### What problem does this PR solve?

Fix metadata config

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
@coderabbitai coderabbitai Bot mentioned this pull request May 26, 2026
1 task done
@dosubot dosubot Bot mentioned this pull request Jun 15, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants