Skip to content

Safe-output comments cannot carry hidden machine-readable state because every HTML comment is stripped #67174

Closed

Description

@jaroslawgajewski

Summary

sanitize_content_core.cjs runs removeXmlComments on every safe-output body (add_comment and the others), so an agent or a post-agent step cannot store hidden, machine-readable state in a comment. gh-aw appends its own markers (<!-- gh-aw-agentic-workflow: ... -->, <!-- gh-aw-workflow-id: ... -->) after sanitization, so hidden markers are an accepted pattern internally but not available to workflow authors.

Use case

An on-demand review that supports -increment needs the commit the previous review covered. We ended every review comment with <!-- gh-aw--state: {"xxx_sha":"..."} --> and read it back from the PR's comment history (the cache-memory alternative does not persist for issue_comment-triggered runs). The marker was present in the agent's safe-output item and in the post-agent step's output, but absent from every comment GitHub stored, so every -increment request failed with "no baseline".

Reproduction

Running sanitizeContent (v0.91.1) on a body that ends with a hidden marker <!-- gh-aw-w-state: {"xxx_sha":"<sha>"} -->:

Marker form Result after sanitization
<!-- ... --> removed
[//]: # (...) [//]: # (content dropped)
[label]: <https://...?x=<sha>> URL replaced with a redacted placeholder
Visible line with the SHA in backticks kept

Expected

One of:

  • a safe-output option that preserves HTML comments whose text starts with an allow-listed prefix (for example allow-html-comments: ["gh-aw-state:"]), still stripping everything else, or
  • a documented, supported way to attach hidden metadata to a safe-output comment.

If neither is wanted, the safe-outputs documentation should say that hidden markers are removed so authors do not rely on them.

Workaround today

Append a visible line and parse that.

Activity

  1. locked and limited conversation to collaborators on Oct 9, 2026
  2. unlocked this conversation on Oct 9, 2026
  3. pelikhan commented on Oct 11, 2026

    @pelikhan
    Collaborator

    /scout research how to use safe-outputs data to store structured data in safe outputs

  4. github-actions commented on Oct 11, 2026

    @github-actions
    Contributor

    ⚠️ Security scanning failed for Scout. Review the logs for details.

    🔭 Intelligence gathered by Scout

  5. github-actions commented on Oct 12, 2026

    @github-actions
    Contributor

    test body

    🔭 Intelligence gathered by Scout · claude · agent · 280.4 AIC · ⊞ 5.3K · ◷
    Comment /scout to run again

  6. pelikhan commented on Oct 16, 2026

    @pelikhan
    Collaborator

    @copilot determine if the "data" feature in safe-outputs provide a solution for this.

  7. pelikhan commented on Oct 16, 2026

    @pelikhan
    Collaborator

    Current-state refresher (2026-10-16): Partially addressed — supported structured state exists, but it is not hidden metadata.

    The maintainer's latest question has a concrete answer: safe-outputs.data can carry the previous-review SHA, provided the workflow enables data (optionally with a schema) and the safe-output item supplies a data object. The current documentation describes this channel; the validator appends it as fenced JSON so it survives sanitization. Regression tests cover this behavior.

    However, add-comment renders a visible “Structured data” JSON block, not an HTML comment. The sanitizer still removes HTML comments. Thus data addresses persistence/machine readability, not the exact hidden-state requirement.

    #69437 is open as a draft with no changed files at inspection. Remaining decision: accept/document the visible structured-data approach or design a separate reviewed hidden-metadata mechanism. Static inspection; tests were read, not run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions