Maven: skip unresolvable properties#14344
Merged
Merged
Conversation
bc2e4aa to
9fe0f03
Compare
74af514 to
87c458f
Compare
1 task
Contributor
Author
|
@kbukum1 Please review if you get a chance. Thanks in advance |
87c458f to
c11402f
Compare
Contributor
There was a problem hiding this comment.
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_placeholdertolerant 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_placeholderis 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.
aabfb84 to
2e82add
Compare
2e82add to
74a7c0d
Compare
kbukum1
approved these changes
Mar 10, 2026
74a7c0d to
3052f86
Compare
kbukum1
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
This change makes
PropertyValueFinder#resolve_property_placeholdertolerant 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?
nilinto T.must #14330 runs successfully after this changeChecklist