Skip to content

feat:[PEA-139] Removed prefix from azure asset id field and falttened…#176

Merged
arunpaladin merged 1 commit into
mainfrom
feat/tagging-azure-fixes
May 20, 2026
Merged

feat:[PEA-139] Removed prefix from azure asset id field and falttened…#176
arunpaladin merged 1 commit into
mainfrom
feat/tagging-azure-fixes

Conversation

@nkeerthana111

@nkeerthana111 nkeerthana111 commented May 20, 2026

Copy link
Copy Markdown

… tags for azure

Summary by CodeRabbit

Release Notes

  • Improvements

    • Enhanced asset document ID generation with improved support for Azure and other cloud providers.
    • Refactored asset tag processing to ensure consistent metadata handling across different cloud sources.
  • Tests

    • Expanded test coverage for asset document ID generation across Azure and GCP resources.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR refactors AssetDocumentHelper to distinguish docId formatting for Azure sources. buildDocId now derives a shared concatenatedId and applies source-specific formatting, while tag population delegates Azure tag handling to a new addFlattenedTags utility. Test coverage validates that Azure docIds remain raw resource IDs and GCP docIds receive the source-type prefix.

Changes

Asset DocId Azure Handling

Layer / File(s) Summary
DocId Formatting and Azure Tag Flattening
assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java
buildDocId refactored to compute concatenatedId once and format docId conditionally based on whether dataSource is Azure. Tag population for both primary asset and update paths now delegates Azure tag handling to addFlattenedTags, which flattens the AssetDocumentFields.TAGS map into the DTO without transformation.
DocId Prefix Test Coverage
assets-management/services/svc-asset-delta-engine/src/test/java/com/paladincloud/commons/assets/AssetDocumentHelperTests.java
New JSON fixture for Azure load balancer mapper document and two assertions: azureDocIdHasNoPrefix confirms Azure docIds match raw resource IDs exactly, and gcpDocIdHasPrefix confirms GCP docIds are prefixed with gcp_ec2_us-central_17.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • arunpaladin
  • plyubich

Poem

🐰 The docId now knows its source—
Azure flows unadorned, while others proudly wear their prefix!
Tags flatten softly, helpers guide the way,
Tests confirm the paths both old and new. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions removing prefix from Azure asset ID and flattening tags, which aligns with the main changes: refactored docId computation for Azure vs non-Azure sources and new addFlattenedTags helper.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tagging-azure-fixes

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.

@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

🧹 Nitpick comments (1)
assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java (1)

529-537: 💤 Low value

Consider adding empty map check for consistency.

While iterating over an empty map is safe, adding an isEmpty() check before the forEach would be consistent with addLegacyTags (line 518) and avoid unnecessary iteration overhead.

♻️ Proposed consistency improvement
 private void addFlattenedTags(Map<String, Object> data, AssetDTO dto) {
     var tagData = data.get(AssetDocumentFields.TAGS);
     if (tagData instanceof Map) {
         `@SuppressWarnings`("unchecked") var tagMap = (Map<String, Object>) tagData;
-        tagMap.forEach((key, value) -> {
-            dto.addType(STR."\{AssetDocumentFields.asTag(key)}", value);
-        });
+        if (!tagMap.isEmpty()) {
+            tagMap.forEach((key, value) -> {
+                dto.addType(STR."\{AssetDocumentFields.asTag(key)}", value);
+            });
+        }
     }
 }
🤖 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
`@assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java`
around lines 529 - 537, In addFlattenedTags, add the same empty-map guard used
in addLegacyTags: after casting tagData to tagMap (Map<String,Object>), check if
tagMap.isEmpty() and return early to avoid the forEach when there are no
entries; this affects the method addFlattenedTags and the usage of
AssetDocumentFields.TAGS and dto.addType (and the AssetDocumentFields.asTag(key)
key formatting) to keep behavior consistent and avoid unnecessary iteration.
🤖 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.

Inline comments:
In
`@assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java`:
- Around line 141-144: The change to docId generation causes Azure entries to
lose the "azure_{type}_" prefix because docId is set to concatenatedId when
dataSource equals "azure"; confirm whether this was intentional and either
revert to the prior Azure format or add explicit migration/compatibility
handling: update the docId assignment in AssetDocumentHelper (variables:
concatenatedId, docId, dataSource, type, and the StringHelper.concatenate call)
so Azure follows the expected "azure_{type}_{concatenatedId}" pattern OR
implement a dual-lookup/migration path that maps old (prefixed) IDs to new ones,
plus update documentation and tests that assert Azure docId semantics.

---

Nitpick comments:
In
`@assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java`:
- Around line 529-537: In addFlattenedTags, add the same empty-map guard used in
addLegacyTags: after casting tagData to tagMap (Map<String,Object>), check if
tagMap.isEmpty() and return early to avoid the forEach when there are no
entries; this affects the method addFlattenedTags and the usage of
AssetDocumentFields.TAGS and dto.addType (and the AssetDocumentFields.asTag(key)
key formatting) to keep behavior consistent and avoid unnecessary iteration.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: a28908c0-9409-46a4-b405-830152e3f8d8

📥 Commits

Reviewing files that changed from the base of the PR and between fc726c3 and 7ddc7e6.

📒 Files selected for processing (2)
  • assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java
  • assets-management/services/svc-asset-delta-engine/src/test/java/com/paladincloud/commons/assets/AssetDocumentHelperTests.java

Comment on lines +141 to +144
var concatenatedId = StringHelper.concatenate(data, docIdFields, "_");
var docId = "azure".equalsIgnoreCase(dataSource)
? concatenatedId
: STR."\{dataSource}_\{type}_\{concatenatedId}";

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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify Java version supports template strings (21+)
if [ -f "pom.xml" ]; then
  echo "=== Java version in pom.xml ==="
  rg -n '<java.version>|<maven.compiler.source>|<maven.compiler.target>' pom.xml
fi

if [ -f "build.gradle" ]; then
  echo "=== Java version in build.gradle ==="
  rg -n 'sourceCompatibility|targetCompatibility' build.gradle
fi

# Search for code that might construct or parse Azure docIds with prefix
echo -e "\n=== Searching for azure docId construction patterns ==="
rg -nP --type=java 'azure.*_.*_' -C2

# Search for migration logic or docId format changes
echo -e "\n=== Searching for docId migration or format handling ==="
rg -nP --type=java 'docId.*azure|azure.*docId' -C2 | head -50

Repository: PaladinCloud/ce-extensions

Length of output: 1049


🏁 Script executed:

#!/bin/bash

# Find pom.xml files in the repository
echo "=== Locating pom.xml files ==="
fd -n "pom.xml" | head -20

# Look for build.gradle
echo -e "\n=== Locating build.gradle files ==="
fd -n "build.gradle" | head -20

Repository: PaladinCloud/ce-extensions

Length of output: 618


🏁 Script executed:

#!/bin/bash

# Once we find pom.xml, check the Java version in the relevant pom.xml
if [ -f "assets-management/services/svc-asset-delta-engine/pom.xml" ]; then
  echo "=== Java version in svc-asset-delta-engine pom.xml ==="
  cat assets-management/services/svc-asset-delta-engine/pom.xml | grep -A2 -B2 "java.version\|maven.compiler"
fi

# Also check parent pom if exists
if [ -f "assets-management/pom.xml" ]; then
  echo -e "\n=== Java version in assets-management pom.xml ==="
  cat assets-management/pom.xml | grep -A2 -B2 "java.version\|maven.compiler"
fi

if [ -f "pom.xml" ]; then
  echo -e "\n=== Java version in root pom.xml ==="
  cat pom.xml | grep -A2 -B2 "java.version\|maven.compiler"
fi

Repository: PaladinCloud/ce-extensions

Length of output: 693


🏁 Script executed:

#!/bin/bash

# Get the full context of the buildDocId method to understand the breaking change
echo "=== Full buildDocId method context ==="
cat -n assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java | sed -n '120,160p'

Repository: PaladinCloud/ce-extensions

Length of output: 2085


🏁 Script executed:

#!/bin/bash

# Search for tests that validate docId generation
echo "=== Searching for docId tests ==="
fd -n "Test\.java$|Tests\.java$" assets-management/services/svc-asset-delta-engine | xargs -I {} bash -c 'grep -l "docId\|buildDocId" "{}" 2>/dev/null && echo "Found in: {}"' | head -10

Repository: PaladinCloud/ce-extensions

Length of output: 353


🏁 Script executed:

#!/bin/bash

# Search for any references to the docId format or Azure docId handling elsewhere in the codebase
echo "=== Searching for docId format documentation or comments ==="
rg -nP --type=java 'docId|buildDocId' assets-management/services/svc-asset-delta-engine/src | head -30

Repository: PaladinCloud/ce-extensions

Length of output: 5665


Confirm the intentional Azure docId format change and verify data migration.

The Java 21 template string syntax is valid and correctly supported. However, the change introduces a breaking format for Azure docIds: from azure_type_resourceid to just resourceid. This affects existing documents stored in Elasticsearch and downstream lookups.

Verify that:

  • This format change is intentional and documented
  • Existing Azure documents are migrated or no longer queried by the old format
  • Any systems that depend on the azure_ prefix for Azure docIds are updated accordingly
🧰 Tools
🪛 PMD (7.24.0)

[High] 144-144: Parse Error: LexException: Lexical error in file 'assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java' at line 144, column 25: "{" (123), after : ""\" (in lexical state DEFAULT)

(Parse Error)

🤖 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
`@assets-management/services/svc-asset-delta-engine/src/main/java/com/paladincloud/common/assets/AssetDocumentHelper.java`
around lines 141 - 144, The change to docId generation causes Azure entries to
lose the "azure_{type}_" prefix because docId is set to concatenatedId when
dataSource equals "azure"; confirm whether this was intentional and either
revert to the prior Azure format or add explicit migration/compatibility
handling: update the docId assignment in AssetDocumentHelper (variables:
concatenatedId, docId, dataSource, type, and the StringHelper.concatenate call)
so Azure follows the expected "azure_{type}_{concatenatedId}" pattern OR
implement a dual-lookup/migration path that maps old (prefixed) IDs to new ones,
plus update documentation and tests that assert Azure docId semantics.

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

Looks good.

@arunpaladin
arunpaladin merged commit dd8532e into main May 20, 2026
7 checks passed
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.

3 participants