Repository: smithy-lang/smithy
Pull request #2616 (2025-05-07 02:24:22)

Fix node loading and serialization of endpoint value
#### Background
* What do these changes do? 
* Why are they important?

#### Testing
* How did you test these changes?

#### Links
* Links to additional context, if necessary
* Issue #, if applicable (see [here](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) for a list of keywords to use for linking issues)

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.



Patch:
diff --git a/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/evaluation/value/EndpointValue.java b/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/evaluation/value/EndpointValue.java
index 701982876..324c71ab9 100644
--- a/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/evaluation/value/EndpointValue.java
+++ b/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/evaluation/value/EndpointValue.java
@@ -25,7 +25,7 @@ import software.amazon.smithy.utils.StringUtils;
  */
 public final class EndpointValue extends Value {
     private static final String PROPERTIES = "properties";
-    private static final String URL = "URL";
+    private static final String URL = "url";
     private static final String HEADERS = "headers";
     private static final List<String> NODE_PROPERTIES = ListUtils.of(PROPERTIES, URL, HEADERS);
 
@@ -60,14 +60,14 @@ public final class EndpointValue extends Value {
         ObjectNode objectNode = node.expectObjectNode("endpoints are object nodes");
         objectNode.expectNoAdditionalProperties(NODE_PROPERTIES);
 
-        objectNode.expectStringMember("url", builder::url);
+        objectNode.expectStringMember(URL, builder::url);
         objectNode.getObjectMember(PROPERTIES, props -> {
             for (Map.Entry<String, Node> entry : props.getStringMap().entrySet()) {
                 builder.putProperty(entry.getKey(), Value.fromNode(entry.getValue()));
             }
         });
 
-        objectNode.getObjectMember("headers", headers -> {
+        objectNode.getObjectMember(HEADERS, headers -> {
             for (Map.Entry<String, Node> entry : headers.getStringMap().entrySet()) {
                 builder.putHeader(entry.getKey(),
                         entry.getValue()


Test patch:
diff --git a/smithy-rules-engine/src/test/java/software/amazon/smithy/rulesengine/language/value/EndpointValueTest.java b/smithy-rules-engine/src/test/java/software/amazon/smithy/rulesengine/language/value/EndpointValueTest.java
new file mode 100644
index 000000000..11734bc96
--- /dev/null
+++ b/smithy-rules-engine/src/test/java/software/amazon/smithy/rulesengine/language/value/EndpointValueTest.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package software.amazon.smithy.rulesengine.language.value;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+import software.amazon.smithy.model.node.Node;
+import software.amazon.smithy.rulesengine.language.evaluation.value.Value;
+
+public class EndpointValueTest {
+    @Test
+    public void loadsFromNode() {
+        Value value = Value.endpointValue(Node.objectNode().withMember("url", "https://foo.com"));
+
+        assertEquals("https://foo.com", value.toNode().expectObjectNode().expectStringMember("url").getValue());
+    }
+}