Skip to content

Maven: skip unresolvable properties#14344

Merged
kbukum1 merged 1 commit into
dependabot:mainfrom
yeikel:fix/unresolved-placeholder
Mar 10, 2026
Merged

Maven: skip unresolvable properties#14344
kbukum1 merged 1 commit into
dependabot:mainfrom
yeikel:fix/unresolved-placeholder

Conversation

@yeikel
Copy link
Copy Markdown
Contributor

@yeikel yeikel commented Mar 3, 2026

What are you trying to accomplish?

This change makes PropertyValueFinder#resolve_property_placeholder tolerant of unresolvable nested properties.

Previously, we assumed that recursive resolution would always return a value but If a nested property could not be resolved, this would raise due to T.must, causing parsing to fail.

Fixes #14330

How will you know you've accomplished your goal?

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@yeikel yeikel changed the title Maven: Skip unresolvable properties Maven: skip unresolvable properties Mar 3, 2026
@github-actions github-actions Bot added the L: java:maven Maven packages via Maven label Mar 3, 2026
@yeikel yeikel force-pushed the fix/unresolved-placeholder branch 5 times, most recently from bc2e4aa to 9fe0f03 Compare March 3, 2026 06:53
@yeikel yeikel closed this Mar 3, 2026
@yeikel yeikel reopened this Mar 3, 2026
@yeikel yeikel force-pushed the fix/unresolved-placeholder branch 2 times, most recently from 74af514 to 87c458f Compare March 3, 2026 07:21
@yeikel yeikel marked this pull request as ready for review March 3, 2026 07:21
@yeikel yeikel requested a review from a team as a code owner March 3, 2026 07:21
@yeikel
Copy link
Copy Markdown
Contributor Author

yeikel commented Mar 3, 2026

@kbukum1 Please review if you get a chance. Thanks in advance

@yeikel yeikel force-pushed the fix/unresolved-placeholder branch from 87c458f to c11402f Compare March 4, 2026 01:33
@kbukum1 kbukum1 requested a review from Copilot March 4, 2026 03:03
@kbukum1 kbukum1 self-assigned this Mar 4, 2026
Copy link
Copy Markdown
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

Improves Maven property resolution so that nested, unresolvable property placeholders don’t raise (via T.must) and instead resolve safely, preventing POM parsing from failing (fixes #14330).

Changes:

  • Make PropertyValueFinder#resolve_property_placeholder tolerant of unresolvable nested properties.
  • Add a new Maven POM fixture with an intentionally undefined nested property.
  • Add a spec covering the undefined-nested-property resolution behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
maven/lib/dependabot/maven/file_parser/property_value_finder.rb Avoids raising when a nested property can’t be resolved during placeholder substitution.
maven/spec/dependabot/maven/file_parser/property_value_finder_spec.rb Adds coverage asserting undefined nested properties resolve to an empty string (and do not error).
maven/spec/fixtures/poms/pom_with_undefined_property.xml Provides a reproducible fixture with an unresolved nested property placeholder.
Comments suppressed due to low confidence (1)

maven/lib/dependabot/maven/file_parser/property_value_finder.rb:134

  • resolve_property_placeholder is annotated as returning a nilable hash, but it always returns a hash literal. Now that the placeholder resolution can yield empty strings, tightening this signature to a non-nilable hash would better reflect reality and prevent nil-handling from creeping into callers.
        sig do
          params(
            content: String,
            callsite_pom: DependencyFile,
            pom: DependencyFile,
            node: T.untyped,
            seen_properties: T::Set[String]
          ).returns(T.nilable(T::Hash[Symbol, T.untyped]))
        end
        def resolve_property_placeholder(content, callsite_pom, pom, node, seen_properties)
          resolved_value = content.gsub(/\$\{(.+?)}/) do
            inner_name = Regexp.last_match(1)
            resolved = property_details(
              property_name: T.must(inner_name),
              callsite_pom: callsite_pom,
              seen_properties: seen_properties
            )
            resolved[:value] if resolved
          end

          { file: pom.name, node: node, value: resolved_value }
        end

You can also share your feedback on Copilot code review. Take the survey.

Comment thread maven/lib/dependabot/maven/file_parser/property_value_finder.rb
@yeikel yeikel force-pushed the fix/unresolved-placeholder branch 2 times, most recently from aabfb84 to 2e82add Compare March 9, 2026 17:29
Copy link
Copy Markdown
Contributor

@kbukum1 kbukum1 left a comment

Choose a reason for hiding this comment

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

LGTM

@kbukum1 kbukum1 force-pushed the fix/unresolved-placeholder branch from 2e82add to 74a7c0d Compare March 10, 2026 20:02
@kbukum1 kbukum1 force-pushed the fix/unresolved-placeholder branch from 74a7c0d to 3052f86 Compare March 10, 2026 20:45
@kbukum1 kbukum1 merged commit ac716b9 into dependabot:main Mar 10, 2026
63 checks passed
@yeikel yeikel deleted the fix/unresolved-placeholder branch March 11, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: java:maven Maven packages via Maven

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_files_error Passed nil into T.must

3 participants