From cb841649986ada8c2747530bfa76c722ecbb2059 Mon Sep 17 00:00:00 2001 From: John Cater Date: Tue, 24 Nov 2020 10:23:14 -0500 Subject: [PATCH] Fix error message from getPrerequisites to not print internal details. Part of work on #11993. --- .../build/lib/query2/cquery/ConfiguredTargetAccessor.java | 4 ++-- .../query2/cquery/ConfiguredTargetQuerySemanticsTest.java | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java b/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java index 4db9b06800a9c2..877d459972271c 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java +++ b/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java @@ -130,8 +130,8 @@ public List getPrerequisites( throw new QueryException( caller, String.format( - "%s %s of type %s does not have attribute '%s'", - errorMsgPrefix, actualConfiguredTarget, rule.getRuleClass(), attrName), + "%sconfigured target of type %s does not have attribute '%s'", + errorMsgPrefix, rule.getRuleClass(), attrName), ConfigurableQuery.Code.ATTRIBUTE_MISSING); } ImmutableList.Builder toReturn = ImmutableList.builder(); diff --git a/src/test/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQuerySemanticsTest.java b/src/test/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQuerySemanticsTest.java index 688550c9f2b499..14e2ec3784f564 100644 --- a/src/test/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQuerySemanticsTest.java +++ b/src/test/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQuerySemanticsTest.java @@ -161,17 +161,14 @@ public void testLabelsFunction_errorsOnBadAttribute() throws Exception { setUpLabelsFunctionTests(); ConfiguredTarget myRule = Iterables.getOnlyElement(eval("//test:my_rule")); - String targetConfiguration = myRule.getConfigurationChecksum(); // Test that the proper error is thrown when requesting an attribute that doesn't exist. EvalThrowsResult evalThrowsResult = evalThrows("labels('fake_attr', //test:my_rule)", true); assertConfigurableQueryCode(evalThrowsResult.getFailureDetail(), Code.ATTRIBUTE_MISSING); assertThat(evalThrowsResult.getMessage()) .isEqualTo( - String.format( - "in 'fake_attr' of rule //test:my_rule: ConfiguredTarget(//test:my_rule, %s) " - + "of type rule_with_transitions does not have attribute 'fake_attr'", - targetConfiguration)); + "in 'fake_attr' of rule //test:my_rule: configured target of type" + + " rule_with_transitions does not have attribute 'fake_attr'"); } @Test