Copilot commented on code in PR #4490:
URL: https://github.com/apache/texera/pull/4490#discussion_r3192638820


##########
common/workflow-core/src/main/scala/org/apache/texera/amber/core/state/State.scala:
##########
@@ -57,6 +58,9 @@ object State {
 
   def fromTuple(row: Tuple): State = fromJson(row.getField[String](Content))
 
+  def uriFromResultUri(resultUri: URI): URI =
+    new URI(resultUri.toString.replace("/result", "/state"))

Review Comment:
   `uriFromResultUri` uses `resultUri.toString.replace("/result", "/state")`, 
which will replace *any* "/result" substring anywhere in the URI, not just the 
final resource-type segment. This can produce incorrect URIs if a path segment 
ever contains "/result" (now or in future URI formats). Prefer replacing only 
the suffix (e.g., require `endsWith("/result")` and `stripSuffix`), or decode 
the VFS URI and reconstruct it with the resource type set to `STATE`.
   



##########
amber/src/main/python/core/models/state.py:
##########
@@ -41,6 +41,10 @@ def from_json(cls, payload: str) -> "State":
     def from_tuple(cls, row: Tuple) -> "State":
         return cls.from_json(row[cls.CONTENT])
 
+    @staticmethod
+    def uri_from_result_uri(result_uri: str) -> str:
+        return result_uri.replace("/result", "/state")

Review Comment:
   `uri_from_result_uri` currently does a plain `result_uri.replace("/result", 
"/state")`, which replaces all occurrences and isn’t constrained to the final 
resource-type segment. To avoid generating incorrect URIs, replace only the 
trailing "/result" (e.g., via `removesuffix`/`endswith` checks) or parse the 
VFS URI and rewrite just the resource type.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to