Skip to content

fix: label values sanitization and normalization#2724

Merged
zakisk merged 5 commits into
tektoncd:mainfrom
filariow:fix-label-value-formatting
May 14, 2026
Merged

fix: label values sanitization and normalization#2724
zakisk merged 5 commits into
tektoncd:mainfrom
filariow:fix-label-value-formatting

Conversation

@filariow
Copy link
Copy Markdown
Contributor

@filariow filariow commented May 13, 2026

📝 Description of the Change

Label values need to respect strict rules.

Valid label value:

  • must be 63 characters or less (can be empty),
  • unless empty, must begin and end with an alphanumeric character ([a-z0-9A-Z]),
  • could contain dashes (-), underscores (_), dots (.), and alphanumerics between.

This contribution ensures that Label Values are sanitized and normalized to respect the rules above.

🔗 Linked GitHub Issue

N/A

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

To help me navigate the codebase, as I'm mostly new to it, and to review the changes before submitting them.
The changes and tests were hand-written.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Signed-off-by: Francesco Ilario filario@redhat.com

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 13, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: filariow / name: Francesco Ilario (d2a9f42)

@zakisk
Copy link
Copy Markdown
Member

zakisk commented May 13, 2026

/ok-to-test

@zakisk
Copy link
Copy Markdown
Member

zakisk commented May 13, 2026

@filariow you need to sign easycla

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the CleanValueKubernetes function to include periods in the character trimming set and adds relevant test cases to verify this behavior. The reviewer identified a potential issue regarding the order of operations, noting that performing trimming before character replacement may lead to invalid Kubernetes label formats. They suggested reordering the logic to perform replacements first, followed by trimming and length validation, and provided a code snippet to implement this improvement.

Comment thread pkg/formatting/k8labels.go Outdated
Label values can't start nor finish with a `.` (dot).
This contribution ensures that any dot at the beginning or
end of a label value is removed.

Signed-off-by: Francesco Ilario <filario@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@filariow filariow force-pushed the fix-label-value-formatting branch from d2a9f42 to ff4697a Compare May 13, 2026 11:24
@zakisk
Copy link
Copy Markdown
Member

zakisk commented May 13, 2026

/ok-to-test

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 13, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.36%. Comparing base (c615efb) to head (3c0e429).
⚠️ Report is 2 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2724      +/-   ##
==========================================
+ Coverage   59.25%   59.36%   +0.10%     
==========================================
  Files         208      208              
  Lines       20573    20626      +53     
==========================================
+ Hits        12191    12244      +53     
  Misses       7610     7610              
  Partials      772      772              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

seanconroy2021 added a commit to seanconroy2021/release-service-catalog that referenced this pull request May 13, 2026
Build Service konflux-ci/build-service#561 changed Repository CR
naming to use the full git URL. PAC truncates the label to 62 chars
but doesn't trim leading dots (tektoncd/pipelines-as-code#2724),
causing PR to be rejected.

Add ensure_safe_pac_label() to detect when truncation would leave
a leading "." and pad the repo name by one char to shift past it.
Assisted-by: Claude
Signed-off-by: Sean Conroy <sconroy@redhat.com>
Signed-off-by: Francesco Ilario <filario@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@mathur07
Copy link
Copy Markdown
Contributor

/retest

Comment thread pkg/formatting/k8labels.go Outdated
Comment thread pkg/formatting/k8labels.go
filariow added 3 commits May 14, 2026 09:26
Signed-off-by: Francesco Ilario <filario@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Francesco Ilario <filario@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Francesco Ilario <filario@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@filariow filariow changed the title fix: label values when dot are present fix: label values sanitization and normalization May 14, 2026
@zakisk
Copy link
Copy Markdown
Member

zakisk commented May 14, 2026

/ok-to-test

@zakisk
Copy link
Copy Markdown
Member

zakisk commented May 14, 2026

/lgtm

Copy link
Copy Markdown

@pipelines-as-code pipelines-as-code Bot left a comment

Choose a reason for hiding this comment

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

Congrats @filariow your PR Has been approved 🎉

✅ Pull Request Approved

Approval Status:

  • Required Approvals: 1
  • Current Approvals: 1

👥 Reviewers Who Approved:

Reviewer Permission Level Approval Status
@zakisk write

📝 Next Steps

  • Ensure all required checks pass
  • Comply with branch protection rules
  • Request a maintainer to merge using the /merge command (or merge it
    directly if you have repository permission).

Automated by the PAC Boussole 🧭

@zakisk
Copy link
Copy Markdown
Member

zakisk commented May 14, 2026

@filariow Thank you for your contribution! 🎉

@zakisk zakisk merged commit a43ae55 into tektoncd:main May 14, 2026
15 of 24 checks passed
@filariow filariow deleted the fix-label-value-formatting branch May 14, 2026 10:52
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.

5 participants