-
Notifications
You must be signed in to change notification settings - Fork 155
Use workflow-id instead of runId for stable island identification #15207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,31 +22,31 @@ function buildAIFooter(workflowName, runUrl) { | |||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Build the island start marker for replace-island mode | ||||||||||||||||||
| * @param {number} runId - Workflow run ID | ||||||||||||||||||
| * @param {string} workflowId - Workflow ID (stable identifier across runs) | ||||||||||||||||||
| * @returns {string} Island start marker | ||||||||||||||||||
| */ | ||||||||||||||||||
| function buildIslandStartMarker(runId) { | ||||||||||||||||||
| return `<!-- gh-aw-island-start:${runId} -->`; | ||||||||||||||||||
| function buildIslandStartMarker(workflowId) { | ||||||||||||||||||
| return `<!-- gh-aw-island-start:${workflowId} -->`; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Build the island end marker for replace-island mode | ||||||||||||||||||
| * @param {number} runId - Workflow run ID | ||||||||||||||||||
| * @param {string} workflowId - Workflow ID (stable identifier across runs) | ||||||||||||||||||
| * @returns {string} Island end marker | ||||||||||||||||||
| */ | ||||||||||||||||||
| function buildIslandEndMarker(runId) { | ||||||||||||||||||
| return `<!-- gh-aw-island-end:${runId} -->`; | ||||||||||||||||||
| function buildIslandEndMarker(workflowId) { | ||||||||||||||||||
| return `<!-- gh-aw-island-end:${workflowId} -->`; | ||||||||||||||||||
|
Comment on lines
+37
to
+38
|
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Find and extract island content from body | ||||||||||||||||||
| * @param {string} body - The body content to search | ||||||||||||||||||
| * @param {number} runId - Workflow run ID | ||||||||||||||||||
| * @param {string} workflowId - Workflow ID (stable identifier across runs) | ||||||||||||||||||
| * @returns {{found: boolean, startIndex: number, endIndex: number}} Island location info | ||||||||||||||||||
| */ | ||||||||||||||||||
| function findIsland(body, runId) { | ||||||||||||||||||
| const startMarker = buildIslandStartMarker(runId); | ||||||||||||||||||
| const endMarker = buildIslandEndMarker(runId); | ||||||||||||||||||
| function findIsland(body, workflowId) { | ||||||||||||||||||
| const startMarker = buildIslandStartMarker(workflowId); | ||||||||||||||||||
| const endMarker = buildIslandEndMarker(workflowId); | ||||||||||||||||||
|
|
||||||||||||||||||
| const startIndex = body.indexOf(startMarker); | ||||||||||||||||||
| if (startIndex === -1) { | ||||||||||||||||||
|
|
@@ -70,12 +70,12 @@ function findIsland(body, runId) { | |||||||||||||||||
| * @param {string} params.operation - Operation type: "append", "prepend", "replace", or "replace-island" | ||||||||||||||||||
| * @param {string} params.workflowName - Name of the workflow | ||||||||||||||||||
| * @param {string} params.runUrl - URL of the workflow run | ||||||||||||||||||
| * @param {number} params.runId - Workflow run ID | ||||||||||||||||||
| * @param {string} params.workflowId - Workflow ID (stable identifier across runs) | ||||||||||||||||||
| * @param {boolean} [params.includeFooter=true] - Whether to include AI-generated footer (default: true) | ||||||||||||||||||
| * @returns {string} Updated body content | ||||||||||||||||||
| */ | ||||||||||||||||||
| function updateBody(params) { | ||||||||||||||||||
| const { currentBody, newContent, operation, workflowName, runUrl, runId, includeFooter = true } = params; | ||||||||||||||||||
| const { currentBody, newContent, operation, workflowName, runUrl, workflowId, includeFooter = true } = params; | ||||||||||||||||||
|
||||||||||||||||||
| const aiFooter = includeFooter ? buildAIFooter(workflowName, runUrl) : ""; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (operation === "replace") { | ||||||||||||||||||
|
|
@@ -85,24 +85,24 @@ function updateBody(params) { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if (operation === "replace-island") { | ||||||||||||||||||
|
||||||||||||||||||
| if (operation === "replace-island") { | |
| if (operation === "replace-island") { | |
| if (!workflowId) { | |
| throw new Error( | |
| "updateBody: 'workflowId' must be a non-empty string for 'replace-island' operation. " + | |
| "Set GH_AW_WORKFLOW_ID or pass a stable workflowId value." | |
| ); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workflowIdis interpolated directly into an HTML comment marker. If it contains-->, newlines, or other unexpected characters, it can break marker structure and potentially enable marker spoofing/injection in the body. Recommend sanitizing/normalizingworkflowIdto a safe character set (and trimming) before building markers (e.g., restrict to[A-Za-z0-9._-]and replace others), and documenting the allowed format.