Repository navigation
Fix metadata config - #14480
Fix metadata config#14480
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRestructures auto-metadata: per-field id renamed Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
266043b to
df7e253
Compare
There was a problem hiding this comment.
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 | 🟠 MajorPotential API validation failure when
valueTypeis undefined.The optional chaining
item.valueType?.toLowerCase()can produceundefinedwhenvalueTypeis not set. However, the backendAutoMetadataField.type(invalidation_utils.py:374) is a required field expectingLiteral["string", "list", "time", "number"].When
valueTypeis undefined, the payload will includetype: 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
📒 Files selected for processing (3)
api/apps/services/dataset_api_service.pyapi/utils/validation_utils.pyweb/src/pages/dataset/components/metedata/hooks/use-manage-modal.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
### What problem does this PR solve? Fix metadata config ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
### What problem does this PR solve? Fix metadata config ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
What problem does this PR solve?
Fix metadata config
Type of change