|
10 | 10 | import os |
11 | 11 | import datetime |
12 | 12 | import logging |
13 | | -from string import Template |
14 | 13 |
|
15 | 14 | from .config import Config |
16 | 15 | from .bedrock_client import BedrockClient |
|
27 | 26 |
|
28 | 27 |
|
29 | 28 | def _render(template_str, **kwargs): |
30 | | - """Render a prompt template safely. Converts {var} to $var for Template.safe_substitute |
31 | | - so untrusted content like PR bodies containing {braces} won't crash or leak.""" |
32 | | - converted = template_str.replace("{", "${") |
33 | | - return Template(converted).safe_substitute(**kwargs) |
| 29 | + """Render a prompt template safely using str.replace per known variable. |
| 30 | + Unlike .format(), this won't crash on untrusted content containing {braces}.""" |
| 31 | + result = template_str |
| 32 | + for key, value in kwargs.items(): |
| 33 | + result = result.replace("{" + key + "}", str(value)) |
| 34 | + return result |
34 | 35 |
|
35 | 36 |
|
36 | 37 | def _load_schema(name): |
@@ -275,7 +276,7 @@ def act(): |
275 | 276 | slack.send_escalation(number, title, html_url, labels) |
276 | 277 | logger.info(f"Responded to #{number}") |
277 | 278 |
|
278 | | - if action == "ESCALATE": |
| 279 | + elif action == "ESCALATE": |
279 | 280 | reason = result.get("reason", "") |
280 | 281 | if reason == "user_dissatisfied": |
281 | 282 | ack = ( |
@@ -309,7 +310,7 @@ def act(): |
309 | 310 | slack.send_escalation(number, title, html_url, labels) |
310 | 311 | logger.info(f"Escalated #{number}") |
311 | 312 |
|
312 | | - if action == "CLOSE" and not is_pr: |
| 313 | + elif action == "CLOSE" and not is_pr: |
313 | 314 | msg = ( |
314 | 315 | "This issue may not be related to the PyDeequ data quality library. " |
315 | 316 | "The maintainer team has been notified and will review." + footer |
|
0 commit comments