Skip to content

fix(bug): Inconsistency when merging fragments with same file name with different profiles#3803

Open
ash-thakur-rh wants to merge 22 commits intoeclipse-jkube:masterfrom
ash-thakur-rh:fix-multi-env-name-resource
Open

fix(bug): Inconsistency when merging fragments with same file name with different profiles#3803
ash-thakur-rh wants to merge 22 commits intoeclipse-jkube:masterfrom
ash-thakur-rh:fix-multi-env-name-resource

Conversation

@ash-thakur-rh
Copy link
Contributor

@ash-thakur-rh ash-thakur-rh commented Nov 24, 2025

Description

Fixes #2758

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • I have read the contributing guidelines
  • I signed-off my commit with a user that has signed the Eclipse Contributor Agreement
  • My code follows the style guidelines of this project
  • I Keep It Small and Simple: The smaller the PR is, the easier it is to review and have it merged
  • I use conventional commits in my commit messages
  • I have performed a self-review of my code
  • I Added CHANGELOG entry
  • I have updated the documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 69.81132% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.20%. Comparing base (1ac4f7c) to head (9fb12ca).
⚠️ Report is 878 commits behind head on master.

Files with missing lines Patch % Lines
.../jkube/kit/common/util/ResourceFileProcessing.java 73.14% 26 Missing and 3 partials ⚠️
.../jkube/kit/common/util/ResourceFileProcessors.java 0.00% 12 Missing ⚠️
...ube/maven/plugin/mojo/build/AbstractJKubeMojo.java 57.14% 6 Missing ⚠️
...va/org/eclipse/jkube/kit/common/util/YamlUtil.java 93.33% 0 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #3803       +/-   ##
=============================================
+ Coverage     59.36%   72.20%   +12.84%     
- Complexity     4586     4871      +285     
=============================================
  Files           500      494        -6     
  Lines         21211    19424     -1787     
  Branches       2830     2588      -242     
=============================================
+ Hits          12591    14026     +1435     
+ Misses         7370     4192     -3178     
+ Partials       1250     1206       -44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ash-thakur-rh ash-thakur-rh marked this pull request as ready for review November 25, 2025 09:50
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

As agreed internally, prior to tackling this PR, we need to add the relevant fix to ensure that jkube-temp is empty before the resource target/goal is started.

@ash-thakur-rh
Copy link
Contributor Author

ash-thakur-rh commented Dec 1, 2025

As agreed internally, prior to tackling this PR, we need to add the relevant fix to ensure that jkube-temp is empty before the resource target/goal is started.

Already taken care in this change with the configuration of ResourceServiceConfig. Is it okay to handle this in this PR, or we handle it in a separate PR?

@manusa
Copy link
Member

manusa commented Dec 2, 2025

Is it okay to handle this in this PR, or we handle it in a separate PR?

The idea was to handle this in a separate PR to ensure that nothing breaks with regards to cleaning up the jkube-temp dirctory.

@ash-thakur-rh ash-thakur-rh force-pushed the fix-multi-env-name-resource branch from 9e65879 to 1e0cca3 Compare December 5, 2025 06:06
@ash-thakur-rh ash-thakur-rh requested a review from manusa December 22, 2025 08:05
new File[]{file2},
outDir,
(source, target) -> yaml2
);
Copy link
Member

Choose a reason for hiding this comment

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

This is very confusing, the signature of the method suggests that multiple files can be processed but in the test we're running the processor once for each file.

The Javadoc also suggests that this method should only be called once per batch of files

Comment on lines +128 to +140
// When - Process first file
ResourceFileProcessor.processFiles(
new File[]{file1},
outDir,
(source, target) -> "content1"
);

// When - Process second file with same name (should overwrite, not merge)
File[] result = ResourceFileProcessor.processFiles(
new File[]{file1},
outDir,
(source, target) -> "content2"
);
Copy link
Member

Choose a reason for hiding this comment

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

same as other comment

Comment on lines +143 to +157
private static boolean isEffectivelyEmpty(String yaml) {
if (yaml == null || yaml.trim().isEmpty()) {
return true;
}
// Remove comments and whitespace to check if there's any actual content
String[] lines = yaml.split("\n");
for (String line : lines) {
String trimmed = line.trim();
// Skip empty lines, comments, and YAML document separator
if (!trimmed.isEmpty() && !trimmed.startsWith("#") && !trimmed.equals("---")) {
return false;
}
}
return true;
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks brittle. I see this is used in the mergeYaml method.
Why not simply deserialize and check if the deserializes object is not empty.

Comment on lines 230 to 235
private File[] getFiles(File[] resourceFiles, File outDir) throws IOException {
return ResourceFileProcessor.processFiles(resourceFiles, outDir, (resource, targetFile) ->
interpolate(resource, kubernetesExtension.javaProject.getProperties(),
kubernetesExtension.getFilter().getOrNull())
);
}
Copy link
Member

Choose a reason for hiding this comment

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

This method is probably not necessary, just move the content of this method to line 227

@ash-thakur-rh ash-thakur-rh force-pushed the fix-multi-env-name-resource branch from 1e0cca3 to 3a2dde2 Compare December 24, 2025 06:07
Comment on lines +149 to +150
Object deserialized = YAML_MAPPER.readValue(yaml, Object.class);
return isDeserializedObjectEmpty(deserialized);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Object deserialized = YAML_MAPPER.readValue(yaml, Object.class);
return isDeserializedObjectEmpty(deserialized);
return YAML_MAPPER.readValue(yaml, Map.class).isEmpty();

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
70.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

Inconsistency when merging a route.yml fragment with two different profiles (commons, demo)

3 participants