Repository navigation
Support name-based artifact upserts in update-issue - #75988
Conversation
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.
|
|
✅ PR Specification Reviewer completed successfully!
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
There was a problem hiding this comment.
Reviewed PR head c83b55996829f638272d83d7230d883be35a48b6 against Safe Outputs MCP Gateway Specification v1.29.20, especially update_issue §7 (artifact upserts) and the shared Issue Artifact Requirements.
Blocking finding: the implementation records the first matching artifact by API/page order rather than the contract-required lowest-numbered matching artifact. This makes name-based updates nondeterministic when duplicate names exist; see the inline comment on actions/setup/js/issue_artifacts.cjs:237. Please select the minimum artifact number and add reversed-order regression coverage, or synchronize the contract if lowest-number selection is not intended.
No specification edits were applied. This was a static review; tests were not run per review instructions.
Generated by PR Specification Reviewer for #75988 · copilot · gpt50 · ~4 AIC · ⌖ ~2 AIC · ⊞ 1.7K
Comment /review-specs to run again
| if (typeof entry.name !== "string" || !["generic", "link", "plan", "embedded_html"].includes(entry.type)) { | ||
| throw new Error(`${ERR_API}: Invalid issue artifact list response; expected a name and supported type`); | ||
| } | ||
| if (!existing.has(entry.name)) existing.set(entry.name, { number: metadata.number, type: entry.type }); |
There was a problem hiding this comment.
The synchronized contract in docs/src/content/docs/specs/safe-outputs-specification.md §7 requires PATCHing the lowest-numbered artifact for a matching sanitized name. This stores only the first artifact encountered in API/page order, which is not guaranteed to be numeric order, so duplicate names can update a higher-numbered artifact and violate deterministic upsert semantics. Track the minimum metadata.number for each name (and add a regression test with reversed ordering), or revise the contract if lowest-number selection is not intentional.
There was a problem hiding this comment.
The upsert now tracks the lowest artifact number for each sanitized name and patches that entry. Commit: 37d15ca.
|
Warning The 🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (343 added lines under 📄 Draft ADR committed:
🔍 Evidence checked
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify that the implementation matches the decision. ❓ Why ADRs MatterADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors, including your future self, will rely on it. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
ADRs are stored in
|
| } | ||
|
|
||
| if (normalizedArgs.artifacts !== undefined) { | ||
| normalizedArgs.artifacts = resolveIssueArtifactPaths(normalizedArgs.artifacts, updateIssueConfig.max_issue_artifacts, updateIssueConfig.max_issue_artifact_size, "update_issue"); |
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found three merge-blocking correctness risks in the artifact upsert path: partial issue updates are reported as generic failures and can be retried, POST retries can duplicate artifacts after ambiguous responses, and update artifacts do not share create_issue temporary-ID/mention sanitization behavior. Inline comments provide details. Static review only; tests were not run per review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~7 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| for (const artifact of artifacts) { | ||
| artifactName = artifact.name; | ||
| const match = existing.get(artifact.name); | ||
| const { data } = await withRetry( |
There was a problem hiding this comment.
This newly added upsert path retries POST via withRetry. If the server accepts the create but the response is lost or a transient 5xx is returned, the retry can create a second artifact with the same name. Subsequent listing only selects the first matching artifact, so the duplicate remains and history diverges. Please avoid automatic retries for non-idempotent POSTs or reconcile by name before retrying.
There was a problem hiding this comment.
The upsert POST now makes one request without automatic retries; PATCH and listing retain retry handling. Commit: 37d15ca.
| function buildIssueUpdateData(item, config) { | ||
| let artifacts; | ||
| try { | ||
| artifacts = sanitizeIssueArtifacts(normalizeIssueArtifacts(item.artifacts, config.max_issue_artifacts, config.max_issue_artifact_size, HANDLER_TYPE), {}); |
There was a problem hiding this comment.
The update path sanitizes artifact bodies with an empty options object, unlike the existing create-issue pipeline, and it never applies the temporary-ID replacement performed for ordinary issue bodies. Consequently artifact content can retain unresolved #aw_... references and can use different mention/alias handling than create_issue, despite the stated requirement to reuse its sanitization. Please share the same replacement and sanitizer options (with regression coverage).
There was a problem hiding this comment.
Artifact preparation now uses the configured mention sanitizer options and replaces temporary issue references using the resolved map and effective target repository before the final UTF-8 limit check. Commit: 37d15ca.
| formatSuccessResult: (issueNumber, issue) => ({ | ||
| ...formatIssueSuccessResult(issueNumber, issue), | ||
| ...(issue.artifacts?.length ? { artifacts: issue.artifacts } : {}), | ||
| ...(issue._artifactError ? { success: false, error: issue._artifactError } : {}), |
There was a problem hiding this comment.
A failed artifact attachment is converted into success: false even after executeIssueUpdate has already committed the issue edit (and possibly some artifact writes). A caller that retries this result will re-append the body or repeat other non-idempotent updates, while the returned error omits the attached artifacts and gives no reliable partial-success signal. Please expose the partial result explicitly (and make retry behavior unambiguous) rather than reporting the whole update as a generic failure.
There was a problem hiding this comment.
Artifact failures now return an explicit partial result with the attached artifacts, issueUpdated, and retryable: false, rather than inviting a blind retry of the full issue update. Commit: 37d15ca.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /codebase-design. Requesting changes on one correctness bug and one missing regression test.
📋 Key Themes & Highlights
Key Themes
- Correctness: duplicate existing artifact names PATCH the first list entry, not the lowest-numbered one the docs promise. Reproduced with a mock client.
- Test gap: no coverage for duplicate names.
- Readability: artifacts are normalized twice in
buildIssueUpdateData.
Positive Highlights
- ✅ Type mismatches fail before any writes, which protects HTML artifacts from sanitized Markdown.
- ✅ Artifact failures are soft, so the issue edit is preserved and reported as partial.
- ✅ Pagination stops on a short page, and the Go and JS tests cover limits and config parsing.
Not Raised
- Artifact sanitization with
{}matches the existing update body path (update_handler_factory.cjs), so it is consistent.
Limits
JS and Go test suites were not run; actions/setup/js/node_modules is absent. Findings are from source reading and a mock-client repro.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.3K
Comment /matt to run again
| let artifacts; | ||
| try { | ||
| artifacts = sanitizeIssueArtifacts(normalizeIssueArtifacts(item.artifacts, config.max_issue_artifacts, config.max_issue_artifact_size, HANDLER_TYPE), {}); | ||
| artifacts = normalizeIssueArtifacts(artifacts, config.max_issue_artifacts, config.max_issue_artifact_size, HANDLER_TYPE); |
There was a problem hiding this comment.
[/codebase-design] buildIssueUpdateData normalizes artifacts twice: once before and once after sanitization. The second call is the post-sanitization size check, but that intent is not visible at the call site, so the pair reads as redundant. Either add a short comment saying so, or move both steps into one named helper such as prepareIssueArtifacts(item, config).
@copilot please address this.
There was a problem hiding this comment.
Moved artifact normalization, sanitization, temporary-ID replacement, and the final size check into the named prepareIssueArtifacts helper. Commit: 37d15ca.
| }); | ||
| }); | ||
|
|
||
| it("adds a version by PATCH on the second run instead of creating a duplicate", async () => { |
There was a problem hiding this comment.
[/tdd] No test covers duplicate existing names, so the lowest-numbered rule is unverified. Add a case where the list returns two plan artifacts (for example #9 then #3) and assert the PATCH targets #3.
💡 Example test
Arrange: the list returns [{number: 9, name: "plan"}, {number: 3, name: "plan"}]. Act: call upsertIssueArtifacts with one plan artifact. Assert: one PATCH to artifact_number: 3 and no POST.
@copilot please address this.
| if (typeof entry.name !== "string" || !["generic", "link", "plan", "embedded_html"].includes(entry.type)) { | ||
| throw new Error(`${ERR_API}: Invalid issue artifact list response; expected a name and supported type`); | ||
| } | ||
| if (!existing.has(entry.name)) existing.set(entry.name, { number: metadata.number, type: entry.type }); |
There was a problem hiding this comment.
[/diagnosing-bugs] Duplicate-name selection contradicts the documented contract. if (!existing.has(entry.name)) keeps the first entry in list order, not the lowest-numbered one. The docs (safe-outputs.md and spec item 7) say to PATCH the lowest-numbered match. A mock-client repro with existing plan artifacts #9 then #3 PATCHes #9.
💡 Suggested fix
const current = existing.get(entry.name);
if (!current || metadata.number < current.number) {
existing.set(entry.name, { number: metadata.number, type: entry.type });
}Add a regression test with duplicates returned out of order.
@copilot please address this.
There was a problem hiding this comment.
Duplicate-name selection now explicitly chooses the minimum artifact number, and the reversed-order regression verifies the documented contract. Commit: 37d15ca.
There was a problem hiding this comment.
🟡 Changes recommended
The change leaves an HTML sanitization vulnerability, breaks existing validation and schema tests, and can mutate issues before rejecting invalid artifact input.
5 open issues
What changed in this PR
Extends gh-aw’s update-issue safe output to publish versioned artifacts on existing issues, reusing the artifact handling available for create-issue.
Changes:
- Adds name-based artifact creation and updates, including artifact-only calls.
- Extends configuration, schemas, types, and guarded file inputs with artifact limits.
- Adds regression coverage, documents the contract, and regenerates affected workflow locks.
| File | Description |
|---|---|
pkg/workflow/update_issue.go |
Parses artifact count and size limits. |
pkg/workflow/update_issue_artifacts_test.go |
Tests limits, compilation, and artifact-only tool support. |
pkg/workflow/tool_description_enhancer.go |
Adds agent-facing artifact constraints. |
pkg/workflow/safe_outputs_validation_config.go |
Accepts artifacts as an issue update field. |
pkg/workflow/safe_outputs_max_validation.go |
Propagates artifact-size parsing errors. |
pkg/workflow/safe_outputs_handler_registry_issues.go |
Emits artifact limits into handler configuration. |
pkg/workflow/safe_output_validation_config_test.go |
Updates artifact validation assertions. |
pkg/workflow/safe_output_blank_fields_test.go |
Updates blank-request validation expectations. |
pkg/workflow/js/safe_outputs_tools.json |
Extends the embedded tool schema with artifact inputs. |
pkg/parser/schemas/main_workflow_schema.json |
Defines update-issue artifact configuration options. |
docs/src/content/docs/specs/safe-outputs-specification.md |
Specifies artifact upserts, validation, and failure handling. |
docs/src/content/docs/reference/safe-outputs.md |
Documents artifact configuration and usage. |
actions/setup/js/update_issue.cjs |
Prepares artifacts and integrates publication results. |
actions/setup/js/update_issue_artifacts.test.cjs |
Tests upserts, pagination, limits, staging, and failures. |
actions/setup/js/types/safe-outputs.d.ts |
Adds body-only artifacts to recorded update requests. |
actions/setup/js/types/safe-outputs-config.d.ts |
Adds typed artifact configuration options. |
actions/setup/js/types/issue-artifacts.type-test.ts |
Checks update artifact types and helper contracts. |
actions/setup/js/safe_outputs_tools.json |
Exposes runtime artifact inputs and guidance. |
actions/setup/js/safe_outputs_mcp_wrapped_arguments.test.cjs |
Updates required-field error expectations. |
actions/setup/js/safe_outputs_handlers.test.cjs |
Tests guarded artifact paths and input limits. |
actions/setup/js/safe_outputs_handlers.cjs |
Resolves artifact paths before recording updates. |
actions/setup/js/issue_artifacts.cjs |
Adds paginated name-based POST/PATCH handling. |
.github/workflows/workflow-health-manager.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/workflow-generator.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/sub-issue-closer.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/smoke-ci.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/pr-sous-chef.lock.yml |
Refreshes embedded update-issue validation. |
.github/workflows/poem-bot.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/lint-monster.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/eslint-monster.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/daily-squid-image-scan.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/bot-detection.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/workflows/aw-failure-investigator.lock.yml |
Refreshes artifact limits and validation metadata. |
.github/skills/agentic-workflows/SKILL.md |
Lists the index-search documentation reference. |
Review effort: Max (auto)
| { | ||
| "name": "update_issue", | ||
| "description": "Update an existing GitHub issue's title, body, labels, assignees, or milestone WITHOUT closing it. This tool is primarily for editing issue metadata and content. REQUIRED: Provide at least one of: status, title, body, labels, assignees, or milestone. While it supports changing status between 'open' and 'closed', use close_issue instead when you want to close an issue with a closing comment. Body updates support replacing, appending to, prepending content, or updating a per-run \"island\" section. IMPORTANT: The behavior of this tool depends on the workflow's `update-issue: target:` configuration. When `target: triggering` (the default), the tool always updates the issue that triggered the workflow and `issue_number` is ignored. When `target: '*'`, the `issue_number` field controls which issue is updated. The tool will fail (not skip silently) when `target: triggering` and there is no triggering issue (e.g., in scheduled or workflow_dispatch workflows).", | ||
| "description": "Update an existing GitHub issue's title, body, labels, assignees, milestone, or artifacts WITHOUT closing it. This tool is primarily for editing issue metadata and content. REQUIRED: Provide at least one of: status, title, body, labels, assignees, milestone, or artifacts. While it supports changing status between 'open' and 'closed', use close_issue instead when you want to close an issue with a closing comment. Body updates support replacing, appending to, prepending content, or updating a per-run \"island\" section. IMPORTANT: The behavior of this tool depends on the workflow's `update-issue: target:` configuration. When `target: triggering` (the default), the tool always updates the issue that triggered the workflow and `issue_number` is ignored. When `target: '*'`, the `issue_number` field controls which issue is updated. The tool will fail (not skip silently) when `target: triggering` and there is no triggering issue (e.g., in scheduled or workflow_dispatch workflows).", |
| function buildIssueUpdateData(item, config) { | ||
| let artifacts; | ||
| try { | ||
| artifacts = sanitizeIssueArtifacts(normalizeIssueArtifacts(item.artifacts, config.max_issue_artifacts, config.max_issue_artifact_size, HANDLER_TYPE), {}); |
|
|
||
| if config.CustomValidation != "requiresOneOf:status,title,body,labels,assignees,milestone" { | ||
| t.Errorf("update_issue customValidation = %q, want %q", config.CustomValidation, "requiresOneOf:status,title,body,labels,assignees,milestone") | ||
| if config.CustomValidation != "requiresOneOf:status,title,body,labels,assignees,milestone,artifacts" { |
|
|
||
| if (artifacts?.length) { | ||
| try { | ||
| const attached = await upsertIssueArtifacts(github, context.repo.owner, context.repo.repo, issueNumber, artifacts, _maxIssueArtifactSize); |
| artifacts = sanitizeIssueArtifacts(normalizeIssueArtifacts(item.artifacts, config.max_issue_artifacts, config.max_issue_artifact_size, HANDLER_TYPE), {}); | ||
| artifacts = normalizeIssueArtifacts(artifacts, config.max_issue_artifacts, config.max_issue_artifact_size, HANDLER_TYPE); |
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: c83b559
|
Sous-chef requested-head: c83b559 |
…attach-artifacts Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
|
🎉 This pull request is included in a new release. Release: |


Issue artifacts were limited to newly created issues. This change lets
update_issuepublish artifacts on an existing issue, adding a version for a matching name rather than creating a duplicate.bodyor guardedpathinputs. Reusecreate-issuesanitization and configurable count/UTF-8 byte limits.{ "type": "update_issue", "artifacts": [ { "name": "Plan", "type": "plan", "body": "Implementation plan" } ] }