Skip to content

Fix bash arithmetic exit status in sync-project-status workflow#3087

Merged
tekton-robot merged 1 commit intotektoncd:mainfrom
vdemeester:fix-bash-arithmetic-sync-workflow
Feb 3, 2026
Merged

Fix bash arithmetic exit status in sync-project-status workflow#3087
tekton-robot merged 1 commit intotektoncd:mainfrom
vdemeester:fix-bash-arithmetic-sync-workflow

Conversation

@vdemeester
Copy link
Member

Changes

Fix bash arithmetic causing script failure in sync-project-status.yml.

The Bug:

SYNCED=0
((SYNCED++))  # Returns 0 (old value) → exit status 1 → script exits with set -e

With postfix increment ((VAR++)), when VAR=0, it returns the old value (0). In bash, ((0)) means exit status 1 (failure). With set -e (GitHub Actions default), this exits the script.

The jq "broken pipe" error in the logs was a symptom - the real cause was the while loop exiting unexpectedly, leaving the jq process feeding it with a broken pipe.

The Fix:
Use prefix increment ((++VAR)) which returns the new value (≥1), so exit status is always 0.

Fixes: https://github.com/tektoncd/plumbing/actions/runs/21625516269

/kind bug

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide
for more details.

Use prefix increment ((++VAR)) instead of postfix ((VAR++)).

With postfix increment, when VAR=0, ((VAR++)) returns the old value (0),
which in bash means exit status 1. With set -e, this exits the script.

Prefix increment returns the new value (≥1), so exit status is always 0.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 3, 2026
@tekton-robot tekton-robot requested review from abayer and dibyom February 3, 2026 09:58
@tekton-robot tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 3, 2026
Copy link
Contributor

@savitaashture savitaashture left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: savitaashture

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 3, 2026
@tekton-robot tekton-robot merged commit 427aeae into tektoncd:main Feb 3, 2026
26 checks passed
@vdemeester vdemeester deleted the fix-bash-arithmetic-sync-workflow branch February 3, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants