Conversation
The parseMessagesConfig function had 12 identical 4-line blocks for parsing string fields from a map. Extract a setStringFromMap helper to eliminate the repetition while preserving identical behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pelikhan
approved these changes
Feb 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors parseMessagesConfig to remove repeated “read string from map and assign” blocks by introducing a small helper, aiming to preserve existing parsing behavior.
Changes:
- Added
setStringFromMaphelper to DRY up string-field extraction frommap[string]any - Updated
parseMessagesConfigto use the helper for all string message fields - Kept
append-only-commentsparsing as a dedicated bool block (with logging)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+37
to
+48
| setStringFromMap(messagesMap, "footer", &config.Footer) | ||
| setStringFromMap(messagesMap, "footer-install", &config.FooterInstall) | ||
| setStringFromMap(messagesMap, "footer-workflow-recompile", &config.FooterWorkflowRecompile) | ||
| setStringFromMap(messagesMap, "footer-workflow-recompile-comment", &config.FooterWorkflowRecompileComment) | ||
| setStringFromMap(messagesMap, "staged-title", &config.StagedTitle) | ||
| setStringFromMap(messagesMap, "staged-description", &config.StagedDescription) | ||
| setStringFromMap(messagesMap, "run-started", &config.RunStarted) | ||
| setStringFromMap(messagesMap, "run-success", &config.RunSuccess) | ||
| setStringFromMap(messagesMap, "run-failure", &config.RunFailure) | ||
| setStringFromMap(messagesMap, "detection-failure", &config.DetectionFailure) | ||
| setStringFromMap(messagesMap, "agent-failure-issue", &config.AgentFailureIssue) | ||
| setStringFromMap(messagesMap, "agent-failure-comment", &config.AgentFailureComment) |
There was a problem hiding this comment.
parseMessagesConfig now sets detection-failure, agent-failure-issue, and agent-failure-comment via the new helper, but the existing TestParseMessagesConfig assertions (in pkg/workflow/safe_outputs_test.go) don’t cover these fields (or append-only-comments). Adding/expanding tests to assert these mappings would help catch accidental key/field mixups during refactors like this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
parseMessagesConfigfunction inpkg/workflow/safe_outputs_config_messages.gohad 12 identical 4-line blocks for parsing string fields from amap[string]any. This PR extracts asetStringFromMaphelper function to eliminate the repetition while preserving identical behavior.Files Simplified
pkg/workflow/safe_outputs_config_messages.go— extractedsetStringFromMaphelper; reducedparseMessagesConfigfrom ~100 to ~50 linesImprovements Made
Reduced Repetition
Before, each string field required 4 lines:
After, each string field is one line:
Applied Project Standards
append-only-comments) retains its own block since it has a log statement and a different typeChanges Based On
Recent changes from:
Testing
gofmt -lproduces no output)go vetpasses (no compile errors or type issues)Review Focus
Please verify:
append-only-commentsfield is still handled separately (it has a debug log call)Automated by Code Simplifier Agent — analyzing code from the last 24 hours
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.org