Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/workflow/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1444,8 +1444,7 @@ func (c *Compiler) parseOnSection(frontmatter map[string]any, workflowData *Work
if reactionStr, ok := reactionValue.(string); ok {
// Validate reaction value
if !isValidReaction(reactionStr) {
validValues := []string{"+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", "eyes"}
return fmt.Errorf("invalid reaction value '%s': must be one of %v", reactionStr, validValues)
return fmt.Errorf("invalid reaction value '%s': must be one of %v", reactionStr, getValidReactions())
}
workflowData.AIReaction = reactionStr
}
Expand Down
31 changes: 21 additions & 10 deletions pkg/workflow/reactions.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package workflow

// validReactions defines the set of valid reaction values
var validReactions = map[string]bool{
"+1": true,
"-1": true,
"laugh": true,
"confused": true,
"heart": true,
"hooray": true,
"rocket": true,
"eyes": true,
}

// isValidReaction checks if a reaction value is valid according to the schema
func isValidReaction(reaction string) bool {
validReactions := map[string]bool{
"+1": true,
"-1": true,
"laugh": true,
"confused": true,
"heart": true,
"hooray": true,
"rocket": true,
"eyes": true,
}
return validReactions[reaction]
}

// getValidReactions returns the list of valid reaction entries
func getValidReactions() []string {
reactions := make([]string, 0, len(validReactions))
for reaction := range validReactions {
reactions = append(reactions, reaction)
}
return reactions
}