Skip to content

Commit 87c458f

Browse files
committed
Maven: skip unresolvable properties
Fixes #14330
1 parent 218b8f2 commit 87c458f

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def resolve_property_placeholder(content, callsite_pom, pom, node, seen_properti
127127
callsite_pom: callsite_pom,
128128
seen_properties: seen_properties
129129
)
130-
T.must(resolved)[:value]
130+
resolved[:value] if resolved
131131
end
132132

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

maven/spec/dependabot/maven/file_parser/property_value_finder_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
its([:value]) { is_expected.to eq("org.reproducer.channels2") }
5454
end
5555

56+
context "when the nested property is undefined" do
57+
let(:base_pom_fixture_name) { "pom_with_undefined_property.xml" }
58+
let(:property_name) { "os.detected.classifier" }
59+
60+
its([:value]) { is_expected.to eq("") }
61+
end
62+
5663
context "when the property name starts with 'project' but not an attribute of the project" do
5764
let(:base_pom_fixture_name) { "property_name_starts_with_project_pom.xml" }
5865
let(:property_name) { "project.dependency.spring-boot.version" }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.reproducer</groupId>
6+
<artifactId>test</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
9+
<properties>
10+
<!-- Property intentionally left unresolved in this fixture:
11+
${nisse.os.classifier} is undefined in the test environment.
12+
Dependabot should not fail the entire job if this happens
13+
-->
14+
<os.detected.classifier>${nisse.os.classifier}</os.detected.classifier>
15+
</properties>
16+
17+
18+
</project>

0 commit comments

Comments
 (0)