Skip to content

Commit 3952b1b

Browse files
katrephilwo
authored andcommitted
Fix error message from getPrerequisites to not print internal details.
Part of work on #11993. Closes #12551. PiperOrigin-RevId: 344131151
1 parent 6b33bdb commit 3952b1b

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public List<ConfiguredTarget> getPrerequisites(
131131
throw new QueryException(
132132
caller,
133133
String.format(
134-
"%s %s of type %s does not have attribute '%s'",
135-
errorMsgPrefix, actualConfiguredTarget, rule.getRuleClass(), attrName),
134+
"%sconfigured target of type %s does not have attribute '%s'",
135+
errorMsgPrefix, rule.getRuleClass(), attrName),
136136
ConfigurableQuery.Code.ATTRIBUTE_MISSING);
137137
}
138138
ImmutableList.Builder<ConfiguredTarget> toReturn = ImmutableList.builder();

src/test/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQuerySemanticsTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,13 @@ public void testLabelsFunction_labelListAttribute() throws Exception {
160160
public void testLabelsFunction_errorsOnBadAttribute() throws Exception {
161161
setUpLabelsFunctionTests();
162162

163-
ConfiguredTarget myRule = Iterables.getOnlyElement(eval("//test:my_rule"));
164-
String targetConfiguration = myRule.getConfigurationChecksum();
165-
166163
// Test that the proper error is thrown when requesting an attribute that doesn't exist.
167164
EvalThrowsResult evalThrowsResult = evalThrows("labels('fake_attr', //test:my_rule)", true);
168165
assertConfigurableQueryCode(evalThrowsResult.getFailureDetail(), Code.ATTRIBUTE_MISSING);
169166
assertThat(evalThrowsResult.getMessage())
170167
.isEqualTo(
171-
String.format(
172-
"in 'fake_attr' of rule //test:my_rule: ConfiguredTarget(//test:my_rule, %s) "
173-
+ "of type rule_with_transitions does not have attribute 'fake_attr'",
174-
targetConfiguration));
168+
"in 'fake_attr' of rule //test:my_rule: configured target of type"
169+
+ " rule_with_transitions does not have attribute 'fake_attr'");
175170
}
176171

177172
@Test

0 commit comments

Comments
 (0)