Copilot commented on code in PR #13587:
URL: https://github.com/apache/trafficserver/pull/13587#discussion_r4232745236


##########
tools/hrw4u/src/hrw_symbols.py:
##########
@@ -413,7 +414,21 @@ def negate_expression(self, term: str) -> str:
         return f"!({t})"
 
     def percent_to_ident_or_func(self, percent: str, section: SectionType | 
None) -> tuple[str, bool]:
-        """Convert percent block to identifier or function call."""
+        """Convert a %{} block to an identifier or function call; trailing 
[MODS] become a "with" clause."""
+        stripped, mods = split_percent_mods(percent)
+        expr, is_func = self._percent_to_ident_or_func(stripped, section)
+
+        if not mods:
+            return expr, is_func
+
+        # A block with no DSL equivalent comes back as %{...}, where the 
modifiers belong
+        # inside the braces rather than in a "with" clause.
+        if expr == stripped:
+            return apply_percent_mods(expr, mods), is_func
+
+        return f"{expr} with {','.join(mods)}", is_func
+

Review Comment:
   `percent_to_ident_or_func()` converts any trailing `[MODS]` on a mapped 
`%{...}` into a DSL `with ...` clause, but HRW4U interpolation/value contexts 
only allow value-modifiers (currently just `NORM`). This can make u4wrh 
generate HRW4U that later fails to parse (e.g., `%{CLIENT-URL:PATH [NOCASE]}` 
would become `inbound.url.path with NOCASE`, which is rejected by the 
value-modifier validation). Consider filtering `mods` to `VALUE_MODIFIERS` when 
producing the `with ...` clause, and either (a) keep non-value modifiers inside 
the `%{...}` via `apply_percent_mods`, or (b) emit a clear error/warning during 
conversion when unsupported value modifiers are present.



-- 
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