feat: add footer: false support to add-comment safe output#18942
feat: add footer: false support to add-comment safe output#18942
footer: false support to add-comment safe output#18942Conversation
|
@copilot, review all existing order fields and footer fields and their usage. Ensure you are not reinventing functionality that already exists. |
- Add Footer field to AddCommentsConfig struct with preprocessing - Pass footer to add_comment handler config builder (respects global footer setting) - Add footer check in add_comment.cjs: conditionally add footer or just XML marker - Add footer field to add-comment JSON schema - Add tests for add-comment footer configuration (per-handler and global inheritance) - Add FAQ entry about suppressing Generated by... text - Add footer tip to add-comment section in safe-outputs.md Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
footer: false support to add-comment safe output
…tency Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Reviewed all existing
|
There was a problem hiding this comment.
Pull request overview
This PR adds footer: false support to the add-comment safe output handler, allowing users to suppress the "Generated by..." attribution line when posting comments, while preserving hidden XML markers for searchability.
Changes:
- Adds
Footer *stringfield toAddCommentsConfigGo struct, with corresponding YAML schema validation and handler config builder wiring. - Implements
includeFooterlogic inadd_comment.cjs, usinggenerateXMLMarkerwhenfooter: false. - Adds tests, documentation (FAQ entry and safe-outputs reference tip) for the new
footer: falseoption onadd-comment.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/add_comment.go |
Adds Footer *string field to AddCommentsConfig struct; preprocesses boolean field before YAML unmarshal |
pkg/workflow/compiler_safe_outputs_config.go |
Wires footer field into add_comment handler config builder using getEffectiveFooterForTemplatable |
pkg/workflow/safe_outputs_footer_test.go |
Adds Go tests for add-comment footer configuration and global footer propagation |
pkg/parser/schemas/main_workflow_schema.json |
Adds footer boolean field to add-comment JSON schema definition |
actions/setup/js/add_comment.cjs |
Implements runtime includeFooter logic using parseBoolTemplatable; adds generateXMLMarker import |
docs/src/content/docs/reference/safe-outputs.md |
Adds footer: false to the example config block and a TIP callout |
docs/src/content/docs/reference/faq.md |
Adds new FAQ entry explaining how to suppress the "Generated by..." footer text |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for _, step := range steps { | ||
| if strings.Contains(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG") { | ||
| parts := strings.Split(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: ") | ||
| if len(parts) == 2 { | ||
| jsonStr := strings.TrimSpace(parts[1]) | ||
| jsonStr = strings.Trim(jsonStr, "\"") | ||
| jsonStr = strings.ReplaceAll(jsonStr, "\\\"", "\"") | ||
| var handlerConfig map[string]any | ||
| err := json.Unmarshal([]byte(jsonStr), &handlerConfig) | ||
| require.NoError(t, err) | ||
|
|
||
| addCommentConfig, ok := handlerConfig["add_comment"].(map[string]any) | ||
| require.True(t, ok, "add_comment handler config should exist") | ||
| assert.Equal(t, false, addCommentConfig["footer"], "add_comment should inherit global footer: false") | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The test in the "global footer: false propagates to add-comment" sub-test iterates over steps to find the GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG env var, but unlike the analogous TestGlobalFooterConfiguration test (line 116), there is no require.Contains guard before the loop to fail the test if no matching step is found. If addHandlerManagerConfigEnvVar emits no steps containing GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG, the loop body (including the require.True(t, ok, ...) assertion) is never reached, and the test passes vacuously. A guard like require.Contains(t, strings.Join(steps, ""), "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG") should be added before the loop, as is done in the adjacent TestGlobalFooterConfiguration test.
| } else { | ||
| // When footer is disabled, only add XML marker for searchability (no visible attribution text) | ||
| processedBody += "\n\n" + generateXMLMarker(workflowName, runUrl); | ||
| } |
There was a problem hiding this comment.
When footer: false, the other handlers (create_issue.cjs, create_pull_request.cjs, create_discussion.cjs) consistently add a generateWorkflowIdMarker (from generate_footer.cjs), which produces <!-- gh-aw-workflow-id: ${workflowId} -->. However, the new add_comment.cjs implementation calls generateXMLMarker (from messages_footer.cjs), which produces a much more complex <!-- gh-aw-agentic-workflow: ..., workflow_id: ..., run: ... --> marker.
This inconsistency also conflicts with the documentation added in faq.md (line 286), which explicitly states that <!-- gh-aw-workflow-id: ... --> will still be included for searchability. The actual marker format added by add_comment.cjs with footer: false uses gh-aw-agentic-workflow: as the prefix (not gh-aw-workflow-id:), and also includes the workflow_id: field only conditionally if GH_AW_WORKFLOW_ID is set.
To be consistent with other handlers and with the documentation, the footer: false path in add_comment.cjs should use the same approach as create_issue.cjs and create_pull_request.cjs: check if (workflowId) and add generateWorkflowIdMarker(workflowId) (imported from generate_footer.cjs).
| }, | ||
| "footer": { | ||
| "type": "boolean", | ||
| "description": "Controls whether AI-generated footer is added to the comment. When false, the visible footer content is omitted but XML markers (workflow-id, metadata) are still included for searchability. Defaults to true.", |
There was a problem hiding this comment.
The footer field description for add-comment says "XML markers (workflow-id, metadata)" but the equivalent description for create_issue's footer field says "XML markers (workflow-id, tracker-id, metadata)". Since add_comment.cjs also adds a tracker-id marker (regardless of the footer setting), the description should mention "tracker-id" as well, to be accurate and consistent.
| "description": "Controls whether AI-generated footer is added to the comment. When false, the visible footer content is omitted but XML markers (workflow-id, metadata) are still included for searchability. Defaults to true.", | |
| "description": "Controls whether AI-generated footer is added to the comment. When false, the visible footer content is omitted but XML markers (workflow-id, tracker-id, metadata) are still included for searchability. Defaults to true.", |
Footerfield toAddCommentsConfigstruct in Gofootertoadd_commentconfig builder incompiler_safe_outputs_config.goadd_comment.cjsJavaScript filefooterfield toadd-commentJSON schema (placed beforegithub-token, consistent with all other handlers)add-commentfooter configurationfaq.mdabout suppressing "Generated by..." textfootertip toadd-commentsection insafe-outputs.mdmake fmt,make lint,make build,make recompile)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.