🔍 Duplicate Code Detected: Update Body and Attribution Pipeline
Analysis of commit 2b4a6df88d5ea6216b577a0af184f9cecff96771
Assignee: @copilot
Duplicate update-handler report - 2026-08-09
Summary
executeIssueUpdate and executePRUpdate both implement the same multi-step body update pipeline: fetch current entity body, derive workflow attribution metadata, generate a history URL, call updateBody, and write the transformed body back into API payloads. The shared block is large enough that future footer or history-link changes are likely to drift.
Duplication Details
Pattern: body update and AI attribution flow in safe-output update handlers
- Severity: Medium
- Occurrences: 2
- Locations:
actions/setup/js/update_issue.cjs (lines 33-117)
actions/setup/js/update_pull_request.cjs (lines 86-167)
- Code Sample:
const workflowName = process.env.GH_AW_WORKFLOW_NAME || "GitHub Agentic Workflow";
const workflowId = process.env.GH_AW_WORKFLOW_ID || "";
const callerWorkflowId = process.env.GH_AW_CALLER_WORKFLOW_ID || "";
const workflowRepo = _workflowRepo || context.repo;
const runUrl = buildWorkflowRunUrl(context, workflowRepo);
const historyUrl =
generateHistoryUrl({
owner: context.repo.owner,
repo: context.repo.repo,
itemType: "...",
workflowCallId: callerWorkflowId,
workflowId,
serverUrl: context.serverUrl,
}) || undefined;
apiData.body = updateBody({
currentBody,
newContent: rawBody,
operation,
workflowName,
runUrl,
workflowId,
includeFooter,
historyUrl,
});
Impact Analysis
- Maintainability: footer, history-link, or workflow metadata changes must be edited in multiple handlers.
- Bug Risk: a subtle behavior fix in one handler can be missed in the other, especially around default operations and body fetch conditions.
- Code Bloat: the duplicated orchestration obscures the entity-specific logic that actually differs.
Refactoring Recommendations
-
Extract a shared body-update helper
- Move current-body loading, workflow attribution assembly, and
updateBody invocation behind a shared helper that accepts an entity fetcher and itemType.
- Estimated effort: 2-3 hours
- Benefits: one place to maintain footer and history-link behavior.
-
Keep entity-specific hooks explicit
- Preserve issue-only behavior such as temporary project replacement and label intent handling through optional pre/post hooks rather than duplicating the full pipeline.
- Estimated effort: 1-2 hours
- Benefits: shared flow without hiding real differences.
Implementation Checklist
Analysis Metadata
- Analyzed Files: targeted review of 14 files within 1,599 eligible changed
.go/.cjs paths in the shallow initial-import snapshot
- Detection Method: Serena-guided analysis and targeted source inspection
- Commit:
2b4a6df88d5ea6216b577a0af184f9cecff96771
- Analysis Date:
2026-08-09T22:01:37Z
Generated by 🔍 Duplicate Code Detector · gpt54 · 103.8 AIC · ⊞ 12.8K · ◷
🔍 Duplicate Code Detected: Update Body and Attribution Pipeline
Analysis of commit
2b4a6df88d5ea6216b577a0af184f9cecff96771Assignee:
@copilotDuplicate update-handler report - 2026-08-09
Summary
executeIssueUpdateandexecutePRUpdateboth implement the same multi-step body update pipeline: fetch current entity body, derive workflow attribution metadata, generate a history URL, callupdateBody, and write the transformed body back into API payloads. The shared block is large enough that future footer or history-link changes are likely to drift.Duplication Details
Pattern: body update and AI attribution flow in safe-output update handlers
actions/setup/js/update_issue.cjs(lines 33-117)actions/setup/js/update_pull_request.cjs(lines 86-167)Impact Analysis
Refactoring Recommendations
Extract a shared body-update helper
updateBodyinvocation behind a shared helper that accepts an entity fetcher anditemType.Keep entity-specific hooks explicit
Implementation Checklist
updateBodyassemblyAnalysis Metadata
.go/.cjspaths in the shallow initial-import snapshot2b4a6df88d5ea6216b577a0af184f9cecff967712026-08-09T22:01:37Z