Skip to content

Fix export failure when masked secret is empty#2766

Closed
plengauer wants to merge 1 commit into
mainfrom
plengauer-patch-4
Closed

Fix export failure when masked secret is empty#2766
plengauer wants to merge 1 commit into
mainfrom
plengauer-patch-4

Conversation

@plengauer

Copy link
Copy Markdown
Owner

No description provided.

@plengauer plengauer requested a review from moflwi January 3, 2026 22:34
@plengauer plengauer self-assigned this Jan 3, 2026
@plengauer plengauer marked this pull request as ready for review January 3, 2026 22:34
Copilot AI review requested due to automatic review settings January 3, 2026 22:34
@plengauer plengauer enabled auto-merge (squash) January 3, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where empty masked secrets cause export failures in the GitHub Actions instrumentation job initialization. The fix adds || true to the grep command to prevent pipeline failures when no non-empty secrets are found.

Key Changes

  • Modified the secrets redaction pipeline to handle empty values gracefully by preventing grep from causing the pipeline to fail when no matches are found

*) echo ::error::Unsupported traces exporter: "${OTEL_TRACES_EXPORTER:-otlp}" && exit 1;;
esac
( set +x && echo "$INPUT_SECRETS_TO_REDACT" | jq -r '. | to_entries[].value' | sed 's/[.[\(*^$+?{|]/\\\\&/g' | xargs -I '{}' echo '::add-mask::{}' ) && mask_patterns="$(echo "$INPUT_SECRETS_TO_REDACT" | jq -r '. | to_entries[].value' | grep -v '^$' | sed 's/[.[\(*^$+?{|]/\\\\&/g')"
( set +x && echo "$INPUT_SECRETS_TO_REDACT" | jq '. | to_entries[].value' -r | ( grep -v '^$' || true ) | sed 's/[.[\(*^$+?{|]/\\\\&/g' | xargs -I '{}' echo '::add-mask::{}' ) && mask_patterns="$(echo "$INPUT_SECRETS_TO_REDACT" | jq -r '. | to_entries[].value' | grep -v '^$' | sed 's/[.[\(*^$+?{|]/\\\\&/g')"

Copilot AI Jan 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second mask_patterns assignment still lacks the || true guard after grep -v '^$', making it inconsistent with the first pipeline. If all secrets are empty, this will cause the same export failure that the first part of the line is trying to fix.

Suggested change
( set +x && echo "$INPUT_SECRETS_TO_REDACT" | jq '. | to_entries[].value' -r | ( grep -v '^$' || true ) | sed 's/[.[\(*^$+?{|]/\\\\&/g' | xargs -I '{}' echo '::add-mask::{}' ) && mask_patterns="$(echo "$INPUT_SECRETS_TO_REDACT" | jq -r '. | to_entries[].value' | grep -v '^$' | sed 's/[.[\(*^$+?{|]/\\\\&/g')"
( set +x && echo "$INPUT_SECRETS_TO_REDACT" | jq '. | to_entries[].value' -r | ( grep -v '^$' || true ) | sed 's/[.[\(*^$+?{|]/\\\\&/g' | xargs -I '{}' echo '::add-mask::{}' ) && mask_patterns="$(echo "$INPUT_SECRETS_TO_REDACT" | jq -r '. | to_entries[].value' | ( grep -v '^$' || true ) | sed 's/[.[\(*^$+?{|]/\\\\&/g')"

Copilot uses AI. Check for mistakes.
@plengauer plengauer closed this Jan 3, 2026
auto-merge was automatically disabled January 3, 2026 23:08

Pull request was closed

@plengauer plengauer deleted the plengauer-patch-4 branch January 3, 2026 23:08
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.

2 participants