Skip to content

fix(models): avoid panic when matching trigger items with regex conditions#1287

Open
devteamaegis wants to merge 1 commit into
bitrise-io:masterfrom
devteamaegis:fix/trigger-regex-match-panic
Open

fix(models): avoid panic when matching trigger items with regex conditions#1287
devteamaegis wants to merge 1 commit into
bitrise-io:masterfrom
devteamaegis:fix/trigger-regex-match-panic

Conversation

@devteamaegis

Copy link
Copy Markdown

What's broken

bitrise trigger-check (and trigger matching generally) panics with interface conversion: interface {} is map[string]interface {}, not string whenever a trigger_map item uses a regex condition, e.g.:

trigger_map:
- push_branch: { regex: "feature-.*" }
  workflow: primary

Why it happens

stringFromTriggerCondition did an unchecked value.(string). Regex conditions are stored as a map ({regex: ...}), not a string, so MatchWithParams -> FirstMatchingTarget panics. The validator already accepts regex-map conditions, so this config is otherwise valid.

Fix

Delegate stringFromTriggerCondition to the existing stringLiteralOrRegex, 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. Full models package test suite stays green.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant