]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ci: base64 encode multiline strings in structured output 41451/head
authorDaan De Meyer <daan@amutable.com>
Wed, 1 Apr 2026 13:47:34 +0000 (15:47 +0200)
committerDaan De Meyer <daan@amutable.com>
Wed, 1 Apr 2026 13:47:34 +0000 (15:47 +0200)
Avoid claude trying to escape characters in the structured JSON by
just having it base64 encode the multiline strings in the structured
JSON.

.github/workflows/claude-review.yml

index 63bcbc6b5da455a77df16c619d8105be4689e5d5..2f9c76990d245acc23ce173a75d265845bd6ba24 100644 (file)
@@ -355,8 +355,11 @@ jobs:
           ## Review result
 
           Produce your review result as structured output. The fields are:
-          - `summary`: Markdown summary for the tracking comment.
+          - `summary`: The markdown summary for the tracking comment, **base64-encoded**.
+            Write the summary to a temporary file first, then encode it with
+            `base64 -w0 /tmp/summary.md` and put the resulting string in this field.
           - `comments`: Array of review comments (same schema as the reviewer output above).
+            The `body` field of each comment must also be **base64-encoded** the same way.
           - `resolve`: REST API IDs of review comment threads to resolve.
           PROMPT
 
@@ -449,7 +452,7 @@ jobs:
                 if (Array.isArray(review.resolve))
                   resolveIds = review.resolve;
                 if (typeof review.summary === "string")
-                  summary = review.summary;
+                  summary = Buffer.from(review.summary, "base64").toString("utf-8");
               } catch (e) {
                 core.warning(`Failed to parse structured output: ${e.message}`);
               }
@@ -480,7 +483,7 @@ jobs:
                   ...(c.side != null && { side: c.side }),
                   ...(c.start_line != null && { start_line: c.start_line }),
                   ...(c.start_side != null && { start_side: c.start_side }),
-                  body: `Claude: **${c.severity}**: ${c.body}`,
+                  body: `Claude: **${c.severity}**: ${Buffer.from(c.body, "base64").toString("utf-8")}`,
                 });
                 posted++;
               } catch (e) {