Skip to content

feat(metadata-editor): merge hydrated and detailed view results#4503

Merged
mergify[bot] merged 1 commit intobox:masterfrom
dlasecki-box:merge-hydrated-and-detailed-views
Apr 15, 2026
Merged

feat(metadata-editor): merge hydrated and detailed view results#4503
mergify[bot] merged 1 commit intobox:masterfrom
dlasecki-box:merge-hydrated-and-detailed-views

Conversation

@dlasecki-box
Copy link
Copy Markdown
Contributor

@dlasecki-box dlasecki-box commented Apr 15, 2026

When both isMetadataRedesign and isConfidenceScoreEnabled are 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:

{ "values": ["uuid-1"], "details": { "confidenceScore": 1, "confidenceLevel": "HIGH" } }

After merge - taxonomy values are hydrated while details are retained:

{ "values": [{ "id": "uuid-1", "displayName": "Japan", "level": "1", "nodePath": [] }], "details":  { "confidenceScore": 1, "confidenceLevel": "HIGH" }}

Non-taxonomy fields and $-prefixed system fields are left untouched.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced metadata retrieval that combines detailed and hydrated data views for more complete information when advanced features are enabled.
  • Tests

    • Added comprehensive test coverage for metadata merging, API calls, and data transformation scenarios.

@dlasecki-box dlasecki-box requested a review from a team as a code owner April 15, 2026 07:05
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

Walkthrough

This change adds functionality to fetch and merge both detailed and hydrated metadata views concurrently. A new getDetailedInstancesWithHydratedTaxonomy method is introduced that orchestrates two API calls and combines their results using a new mergeDetailedAndHydratedInstances utility function. The existing getInstances method now routes to this new flow when both metadata redesign and confidence score features are enabled.

Changes

Cohort / File(s) Summary
Core Implementation
src/api/Metadata.js, src/api/utils.js
Added getDetailedInstancesWithHydratedTaxonomy method for concurrent fetching of detailed and hydrated views. Introduced mergeDetailedAndHydratedInstances utility that indexes hydrated entries by $id and merges detailed field values while preserving system fields and structure.
Test Coverage
src/api/__tests__/Metadata.test.js, src/api/__tests__/utils.test.js
Updated getInstances test to verify dual xhr.get calls and merged output. Added comprehensive test suite for merge behavior including field replacement, unmatched entry handling, system field preservation, and multi-instance scenarios.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • Lindar90
  • tjuanitas
  • jfox-box

Poem

🐰 Two views meet in the API hall,
Detailed whispers, hydrated calls,
Merged with care by a gentle function,
Fields aligned in perfect conjunction—
Metadata confidence blooms at last! 🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: merging hydrated and detailed view results in the metadata editor.
Description check ✅ Passed The description provides a clear explanation of the problem, solution, and concrete before/after examples, though it lacks the repository's template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3c3dba9 and ca8c5cb.

📒 Files selected for processing (4)
  • src/api/Metadata.js
  • src/api/__tests__/Metadata.test.js
  • src/api/__tests__/utils.test.js
  • src/api/utils.js

Comment thread src/api/Metadata.js
Comment thread src/api/utils.js
Comment thread src/api/Metadata.js
Copy link
Copy Markdown
Contributor

@Lindar90 Lindar90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one question regarding silent errors

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 15, 2026

Merge Queue Status

  • Entered queue2026-04-15 15:24 UTC · Rule: Automatic strict merge
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-15 15:24 UTC · at ca8c5cb5172298c1309a39054fe88fcafce71876

This pull request spent 22 seconds in the queue, including 3 seconds running CI.

Required conditions to merge

@mergify mergify Bot merged commit 6a64717 into box:master Apr 15, 2026
10 of 11 checks passed
@mergify mergify Bot removed the queued label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants