Skip to content

[FIX] Variation id in sensi result is not enriched with element names#3946

Open
thangqp wants to merge 2 commits into
mainfrom
enrich_sensi_result_with_element_names
Open

[FIX] Variation id in sensi result is not enriched with element names#3946
thangqp wants to merge 2 commits into
mainfrom
enrich_sensi_result_with_element_names

Conversation

@thangqp
Copy link
Copy Markdown
Contributor

@thangqp thangqp commented May 15, 2026

PR Summary

This is only a proposal solution which enrich element names for variation id after fetching the result DTO.
However, there is not any solution at frontend to export sensi result with enriched variation id.

Signed-off-by: Thang PHAM <phamthang37@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds UUID extraction and name resolution utilities to support enriching sensitivity analysis results with human-readable element names. Two utility functions handle parsing and mapping UUIDs within variation identifiers, integrated into the sensitivity analysis service to resolve opaque varId values before returning results.

Changes

Sensitivity Analysis Result Enrichment

Layer / File(s) Summary
UUID extraction and resolution utilities
src/services/study/sensitivity-analysis-utils.ts
Exports extractUuidsFromVariationId to parse UUID substrings from variation IDs and resolveForVariationId to perform UUID-to-name mapping while preserving unmapped UUIDs.
Utility function tests
src/services/study/sensitivity-analysis-utils.test.ts
Validates UUID extraction from standard and multi-UUID formats, handles edge cases (no UUIDs, empty input), and verifies name resolution with known/unknown UUIDs and suffix preservation.
Sensitivity analysis enrichment
src/services/study/sensitivity-analysis.ts
Updates imports, makes fetchSensitivityAnalysisResult async, extracts referenced UUIDs, fetches element names in one call, and enriches sensitivities by replacing varId values with resolved names.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: enriching variation IDs with element names in sensitivity results, which aligns with the changeset's primary purpose.
Description check ✅ Passed The description is related to the changeset, explaining that it enriches element names for variation IDs after fetching the result DTO, though it notes this is a proposal without frontend export functionality.
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

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

Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
src/services/study/sensitivity-analysis-utils.test.ts (1)

48-91: ⚡ Quick win

Consider adding a test case for mixed-case UUIDs.

The test suite is comprehensive, but all test UUIDs are lowercase. To ensure robustness, consider adding a test case that verifies behavior with uppercase or mixed-case UUIDs, especially given that the UUID_REGEX uses the case-insensitive flag.

🧪 Proposed test case for case sensitivity
+    it('handles uppercase UUIDs correctly', () => {
+        const varId = '[1E34A601-FB40-4DF1-8DC6-09AAC5EF717E] (REGULAR)';
+        const map = new Map([['1e34a601-fb40-4df1-8dc6-09aac5ef717e', 'FilterA']]);
+        // Should resolve if implementation normalizes case
+        expect(resolveForVariationId(varId, map)).toBe('[FilterA] (REGULAR)');
+    });
🤖 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 `@src/services/study/sensitivity-analysis-utils.test.ts` around lines 48 - 91,
Add a test to the resolveVarId suite that verifies mixed-case UUIDs are matched
correctly (since UUID_REGEX is case-insensitive): within the
describe('resolveVarId') block add an it(...) case that passes a varId
containing an uppercase or mixed-case UUID (e.g.,
'...[1E34A601-FB40-4DF1-8DC6-09AAC5EF717E]...') and a Map whose key is the
lowercase UUID string used elsewhere, then assert resolveForVariationId returns
the mapped name (confirming resolveForVariationId handles case-insensitive UUID
matching against the Map).
🤖 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 `@src/services/study/sensitivity-analysis-utils.test.ts`:
- Around line 48-91: Add a test to the resolveVarId suite that verifies
mixed-case UUIDs are matched correctly (since UUID_REGEX is case-insensitive):
within the describe('resolveVarId') block add an it(...) case that passes a
varId containing an uppercase or mixed-case UUID (e.g.,
'...[1E34A601-FB40-4DF1-8DC6-09AAC5EF717E]...') and a Map whose key is the
lowercase UUID string used elsewhere, then assert resolveForVariationId returns
the mapped name (confirming resolveForVariationId handles case-insensitive UUID
matching against the Map).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32511c32-6688-45aa-bcdb-caba30b98b81

📥 Commits

Reviewing files that changed from the base of the PR and between 5f36c19 and 69e6bda.

📒 Files selected for processing (3)
  • src/services/study/sensitivity-analysis-utils.test.ts
  • src/services/study/sensitivity-analysis-utils.ts
  • src/services/study/sensitivity-analysis.ts

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant