feat(metadata-editor): merge hydrated and detailed view results#4503
Conversation
WalkthroughThis change adds functionality to fetch and merge both detailed and hydrated metadata views concurrently. A new Changes
Sequence DiagramsequenceDiagram
participant Client
participant Metadata as Metadata.getInstances()
participant API as HTTP (xhr)
participant Utils as mergeDetailedAndHydratedInstances()
Client->>Metadata: getInstances(id, isMetadataRedesign=true, isConfidenceScoreEnabled=true)
activate Metadata
Metadata->>Metadata: Compute requestId
Metadata->>Metadata: Call getDetailedInstancesWithHydratedTaxonomy()
par Concurrent Requests
Metadata->>API: GET ?view=detailed
Metadata->>API: GET ?view=hydrated
and
API-->>Metadata: detailedEntries[]
API-->>Metadata: hydratedEntries[]
end
Metadata->>Utils: mergeDetailedAndHydratedInstances(detailedEntries, hydratedEntries)
activate Utils
Utils->>Utils: Index hydratedEntries by $id
Utils->>Utils: Map detailedEntries, replace field values with hydrated data
Utils-->>Metadata: merged results
deactivate Utils
Metadata-->>Client: merged Array<MetadataInstanceV2>
deactivate Metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.1)src/api/__tests__/Metadata.test.jsThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/api/Metadata.js`:
- Around line 408-421: The current parallel fetch returns [] if the hydrated
view fails; change it so that if this.xhr.get for `${baseUrl}?view=hydrated`
throws a non-user-correctable error we still return the detailedEntries from the
successful `${baseUrl}?view=detailed` call. Keep rethrowing for user-correctable
errors via isUserCorrectableError(status). Locate the Promise.all block and
error catch around this.xhr.get, and modify the error handling so failures of
the hydrated call fall back to returning the result of getProp(detailedResponse,
'data.entries', []) and only rethrow when isUserCorrectableError(status) is
true; preserve the mergeDetailedAndHydratedInstances(detailedEntries,
hydratedEntries) path when both succeed.
In `@src/api/utils.js`:
- Around line 119-123: The current assignment in the block using
isDetailedFieldValue(merged[key]) and key in hydratedEntry overwrites detailed
field values for any hydrated payload; restrict this to only apply when the
hydrated value is taxonomy-shaped. Update the condition around merged[key]
assignment (the code referencing merged, hydratedEntry, key, and values) to also
check a predicate like isTaxonomyHydratedValue(hydratedEntry[key]) (or inline
checks for the expected taxonomy shape) and only then replace
merged[key].values; leave non-taxonomy detailed fields untouched.
🪄 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: 8d5c651c-ca0f-4df0-a908-be979da95e13
📒 Files selected for processing (4)
src/api/Metadata.jssrc/api/__tests__/Metadata.test.jssrc/api/__tests__/utils.test.jssrc/api/utils.js
Lindar90
left a comment
There was a problem hiding this comment.
Approved with one question regarding silent errors
Merge Queue Status
This pull request spent 22 seconds in the queue, including 3 seconds running CI. Required conditions to merge
|
When both
isMetadataRedesignandisConfidenceScoreEnabledare enabled, the metadata API previously fetched only the detailed view (which contains confidence score details but returns raw taxonomy UUIDs instead of display names).This PR changes the approach to fetch both the detailed and hydrated views in parallel, then merge them — preserving the detailed field metadata (e.g. confidenceScore, confidenceLevel, etc.) while replacing raw taxonomy UUID arrays with fully hydrated objects (id, displayName, level, nodePath).
Before - a taxonomy field in detailed view:
After merge - taxonomy values are hydrated while details are retained:
Non-taxonomy fields and $-prefixed system fields are left untouched.
Summary by CodeRabbit
Release Notes
New Features
Tests