Add sanitization-safe metadata channel for body-based safe outputs - #48363
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
metadata channel for body-based safe outputs
|
@copilot rename "metadata" to "data" to reflect HTML custom data attributes wording. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot create reusable type and typeref in main json type to avoid duplication |
There was a problem hiding this comment.
Pull request overview
Adds a structured safe-output channel intended to survive body sanitization.
Changes:
- Adds structured
dataschema fields and validator handling. - Appends structured data as fenced JSON.
- Documents behavior and adds validator tests.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/js/safe_outputs_tools.json |
Adds structured-data inputs. |
actions/setup/js/safe_output_type_validator.cjs |
Validates and appends structured data. |
actions/setup/js/safe_output_type_validator.test.cjs |
Adds regression tests. |
docs/src/content/docs/reference/safe-outputs.md |
Documents the structured channel. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Medium
| "data": { | ||
| "type": "object", | ||
| "description": "Optional structured data to carry machine-readable context through sanitization-safe channels. When provided, this object is preserved and appended to the body as fenced JSON.", | ||
| "additionalProperties": true |
| The text output by AI agents is automatically sanitized to prevent injection of malicious content and ensure safe rendering on GitHub. The auto-sanitization applied is: XML escaped, HTTPS only, domain allowlist (GitHub by default), 0.5MB/65k line limits, control char stripping. | ||
|
|
||
| HTML/XML comments (`<!-- ... -->`) are removed from sanitized body fields. | ||
| If you need a machine-readable channel that survives sanitization, add a top-level `data` object on safe outputs that support `body`. The validator preserves `data` and appends it to the body as fenced JSON: |
| // If this safe-output type supports a body field, append structured data | ||
| // as fenced JSON so it survives body sanitization. | ||
| if (Object.prototype.hasOwnProperty.call(typeConfig.fields, "body")) { | ||
| const dataBlock = `${STRUCTURED_DATA_LABEL}\n\`\`\`json\n${dataJSON}\n\`\`\``; |
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in cd9b343: introduced a reusable |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in c844fa9. The reusable shared
Done — I ran the pr-finisher flow and applied the actionable follow-up fix in c844fa9. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in ca5d682.
|
|
@copilot add tests and specification w3c style for schema syntax |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in 0b6e32a.
|
🤖 PR Triage
Adds first-class structured metadata channel to prevent silent loss of machine-readable markers in safe-output sanitization. Substantive but well-scoped (1381 adds, 118 dels, 26 files). AI reviewer approved.
|
|
@copilot enable data with a simple schema on a few agentic workflows in this repo |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in 099308d. Enabled
Also updated strict frontmatter schema acceptance for |
|
@copilot update safeoutputs step summary renderers in JavaScript to render data as code region |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot resolve the merge conflicts on this branch. |
Implemented in e7e4ac3. Updated JavaScript safe-output step summary renderers to show
|
|
@copilot resolve the merge conflicts on this branch. |
Safe-output sanitization intentionally strips HTML/XML comments (
<!-- ... -->), which causes silent loss of machine-readable markers embedded in bodies. This change adds a first-class structured metadata path that survives sanitization while keeping existing body sanitization behavior intact.Validator: structured metadata support
safe_output_type_validator.cjsnow accepts optional top-levelmetadata(object only).normalizedItem.metadata.bodyfield, metadata is appended as fenced JSON under a stable label (Structured metadata:), so downstream automation can parse it safely.Tool schemas: explicit
metadatainputmetadataobject support inpkg/workflow/js/safe_outputs_tools.jsonfor body-bearing tools:create_issueadd_commentcreate_pull_requestcreate_pull_request_review_commentsubmit_pull_request_reviewreply_to_pull_request_review_commentDocs: sanitizer behavior + recommended pattern
metadataas the supported structured channel.Targeted regression coverage
{ "type": "add_comment", "body": "Review complete. All criteria pass.", "metadata": { "verdict": "APPROVE", "criteria_passed": 5 } }pr-sous-chef run: https://github.com/github/gh-aw/actions/runs/30293408015