Skip to content

Add commitStatusDescriptionExpr to Provider API - #1437

Open
schdief wants to merge 1 commit into
fluxcd:mainfrom
schdief:commit-status-description-expr
Open

schdief wants to merge 1 commit into
fluxcd:mainfrom
schdief:commit-status-description-expr

Conversation

@schdief

@schdief schdief commented Nov 16, 2026

Copy link
Copy Markdown

Fixes #1436

Adds the optional field spec.commitStatusDescriptionExpr to the v1 Provider API. It's a CEL
expression that sets the description of the commit statuses posted by the github, gitlab,
gitea, bitbucket, bitbucketserver and azuredevops provider types. Today the description
is always derived from the event reason (e.g. health check failed), so the actual error isn't
visible on the commit.

apiVersion: notification.toolkit.fluxcd.io/v1
kind: Provider
metadata:
  name: github-status
  namespace: apps
spec:
  type: github
  address: https://github.com/org/repo
  secretRef:
    name: github-token
  commitStatusDescriptionExpr: "event.severity == 'error' ? event.message : ''"

Behaviour:

  • Same variables as commitStatusExpr (event, alert, provider). The expression is compiled
    without an output type and EvaluateString rejects non-string results, because field
    selections like event.message are of type dyn and fail the exact output type check in
    runtime/cel.
  • The result is collapsed to one line and shortened in the middle with … to the provider's
    description limit, keeping its start and end (rune-safe).
  • An empty result falls back to the default description.
  • An evaluation error is logged and falls back to the default description. Unlike
    commitStatusExpr, the event isn't dropped: the description is informational, and the commit
    status itself is still correct.
  • When the field isn't set, nothing changes.
  • The CRD rejects the field on other provider types, like commitStatusExpr.

Description limits:

Provider Limit Source
github 140 API returns 422 above 140 (example); not in the REST docs
gitlab 255 GitLab commits API
bitbucketserver 255 Bitbucket Server build REST API
gitea 140 No limit (TEXT column); GitHub's value for readability
bitbucket 140 Not documented; safe default
azuredevops 140 Not documented; safe default

For Bitbucket Server, the build status name keeps the reason (<commitStatus> [<reason>]), as
before; only the description uses the expression.

Tests cover the shortening, each notifier, CEL cases including the error and non-string
fallbacks, and the CRD validation. make test steps pass locally (Go 1.27, envtest 1.37).

This is independent of #1434, which also touches internal/notifier/github.go; whichever merges
second needs a trivial rebase.

Add the optional CEL field spec.commitStatusDescriptionExpr to the v1
Provider API. It sets the description of the commit statuses posted by
the github, gitlab, gitea, bitbucket, bitbucketserver and azuredevops
provider types, while spec.commitStatusExpr sets their context. This
allows showing the event message, e.g. the error of a failed health
check, on the commit instead of only the event reason.

The expression has the same event, alert and provider variables as
spec.commitStatusExpr. The result is collapsed to a single line and
shortened in the middle to the description limit of the provider type
(255 characters for GitLab and Bitbucket Server, 140 for the others),
keeping its start and end. An empty result falls back to the default
description derived from the event reason. An evaluation error is
logged and also falls back to the default description, so that the
commit status is still sent.

The string output type is checked on evaluation rather than on
compilation, as field selections on the event variable such as
event.message are of dynamic type.

When the field is not set, the commit status is unchanged.

Signed-off-by: Steve Lohr <schdief.law@gmail.com>
Assisted-by: copilot/claude-opus-5.5
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.

Commit status: opt-in event message as description (spec.commitStatusDescriptionExpr)

1 participant