fix(models): avoid panic when matching trigger items with regex conditions#1287
Open
devteamaegis wants to merge 1 commit into
Open
fix(models): avoid panic when matching trigger items with regex conditions#1287devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
…tions stringFromTriggerCondition did an unchecked type assertion to string, so MatchWithParams panicked when a trigger map item used a regex condition (stored as a map, not a string). Delegate to stringLiteralOrRegex, which already handles string literals, regex maps and nil.
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.
What's broken
bitrise trigger-check(and trigger matching generally) panics withinterface conversion: interface {} is map[string]interface {}, not stringwhenever atrigger_mapitem uses a regex condition, e.g.:Why it happens
stringFromTriggerConditiondid an uncheckedvalue.(string). Regex conditions are stored as a map ({regex: ...}), not a string, soMatchWithParams->FirstMatchingTargetpanics. The validator already accepts regex-map conditions, so this config is otherwise valid.Fix
Delegate
stringFromTriggerConditionto the existingstringLiteralOrRegex, which already handles nil, plain strings, and the regex-map shapes — returning the regex string instead of panicking. Behavior is unchanged for existing string/nil inputs.Test
Added
TestTriggerMapItemModel_MatchWithParams_RegexCondition, which panics before the change and passes after. Fullmodelspackage test suite stays green.