Skip to content

Commit 997df0d

Browse files
authored
[chore][add-labels.sh] Trim label comment to fix matching (#34796)
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> [Example failure](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/10494185404/job/29069879053), because of [this comment](#34792 (comment)). The failure is happening because the match fails when the label has a trailing newline. Local test without fix: ``` $ export LABEL="os:windows " $ if [[ -v COMMON_LABELS["${LABEL}"] ]]; then echo "Hello"; fi $ ``` Local test with fix: ``` $ export LABEL="os:windows " $ LABEL=$(echo "${LABEL}" | tr -d '\n') $ if [[ -v COMMON_LABELS["${LABEL}"] ]]; then echo "Hello"; fi Hello ```
1 parent 97d2a4d commit 997df0d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

.github/workflows/scripts/add-labels.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ LABELS=$(echo "${COMMENT}" | sed -E 's%^/label%%')
3333

3434
for LABEL_REQ in ${LABELS}; do
3535
LABEL=$(echo "${LABEL_REQ}" | sed -E s/^[+-]?//)
36-
SHOULD_ADD=true
36+
# Trim newlines from label that would cause matching to fail
37+
LABEL=$(echo "${LABEL}" | tr -d '\n')
3738

39+
SHOULD_ADD=true
3840
if [[ "${LABEL_REQ:0:1}" = "-" ]]; then
3941
SHOULD_ADD=false
4042
fi

0 commit comments

Comments
 (0)