From 8811e27353c2c10980faf7e4c5e44b431d2d4f1c Mon Sep 17 00:00:00 2001 From: John Cater Date: Tue, 24 Nov 2020 14:20:23 -0800 Subject: [PATCH] Fix error message from getPrerequisites to not print internal details. Part of work on #11993. Closes #12551. PiperOrigin-RevId: 344131151 --- .../lib/query2/cquery/ConfiguredTargetAccessor.java | 4 ++-- .../cquery/ConfiguredTargetQuerySemanticsTest.java | 9 ++------- 2 files changed, 4 insertions(+), 9 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 09552325e9db72..effb45670025eb 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 @@ -131,8 +131,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..e4b78705b774f8 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 @@ -160,18 +160,13 @@ public void testLabelsFunction_labelListAttribute() throws Exception { 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