Skip to content

Conversation

@bd-samratmuk
Copy link
Contributor

@bd-samratmuk bd-samratmuk commented Nov 19, 2025

Root Cause
The GradleReportConfigurationParser was incorrectly parsing lines from the Gradle dependency report that represent constraints (indicated by a (c) suffix) and treating them as actual dependencies. This resulted in an inaccurate dependency graph where version constraints were mistakenly included as project dependencies. The actual resolved dependencies are listed elsewhere in the dependency tree, so these constraint lines should be ignored.

The Fix

  • Filter out and ignore any line that ends with (c). This ensures that only lines representing actual, resolved dependencies are passed to the GradleReportLineParser.
  • Added a functional test case for the same

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a parsing issue in the Gradle dependency report configuration parser where constraint lines (marked with "(c)") were incorrectly treated as actual dependencies, leading to an inaccurate dependency graph.

Key Changes:

  • Added filtering logic to skip constraint lines ending with "(c)" in the dependency report
  • Ensures only actual resolved dependencies are parsed into the dependency graph

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

children.add(parser.parseLine(line, metadata));
if (!line.trim().endsWith("(c)")) {
children.add(parser.parseLine(line, metadata));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it at all possible for a dependency constraint to not be elsewhere in the tree? Based on what Gradle says “(c) - A dependency constraint, not a dependency. The dependency affected by the constraint occurs elsewhere in the tree.“ it sounds like the answer is no but I wonder if we should add a fallback ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is responsible for checking every line irrespective of the level hence it's added here as (c) can occur in any level.

Copy link
Contributor

@shantyk shantyk left a comment

Choose a reason for hiding this comment

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

I suggest adding a test case for a tree that has a transitive dependency constraint + rich version. @devmehtabd is more familiar with rich versions but it might be relevant.

@devmehtabd
Copy link
Contributor

I suggest adding a test case for a tree that has a transitive dependency constraint + rich version. @devmehtabd is more familiar with rich versions but it might be relevant.

We already have an integration test for gradle rich versions, so if that test passes, we should be good. But I suggest adding some functional or unit tests for the same.

@bd-samratmuk bd-samratmuk merged commit 170147b into master Nov 26, 2025
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.

5 participants