Skip to content

fix: truncate each tag individually in multi-tag templates#655

Merged
nookyo merged 1 commit intomainfrom
654-bug-incorrect-tags-truncating-during-build
Mar 16, 2026
Merged

fix: truncate each tag individually in multi-tag templates#655
nookyo merged 1 commit intomainfrom
654-bug-incorrect-tags-truncating-during-build

Conversation

@nookyo
Copy link
Copy Markdown
Collaborator

@nookyo nookyo commented Mar 16, 2026

Summary

Fix incorrect tag truncation in metadata-action when default-template produces multiple comma-separated tags. Previously, the entire rendered string was truncated as a single value, which caused trailing tags (e.g. {{short-sha}}) to be silently dropped. Now each tag is truncated independently.

Issue

Fixes #654

Breaking Change?

  • Yes
  • No

Scope / Project

actions/metadata-action

Implementation Notes

The root cause was in src/index.js: after fillTemplate() renders the template string, the result was passed directly to truncateTag() as one string. For a template like:

"{{ref-name}}-{{timestamp}}, {{ref-name}}-{{short-sha}}, {{ref-name}}, {{short-sha}}"

this produced a 155-char string that got sliced to 128, cutting off the last tags entirely.

Fix: split the rendered string by ,, trim each part, truncate each tag individually to tag-max-length, then rejoin with ", ". Extra tags (from extra-tags input) were already handled per-tag and required no changes.

Documentation in README.md updated to reflect the new per-tag truncation behavior, including an example from the original bug report.

Tests / Evidence

New integration test added in tests/integration.index.render.test.js:

"should truncate each tag individually when template contains multiple comma-separated tags"

Simulates a long branch name (fix-increase-integration-tests-memory) with template producing 4 comma-separated tags. Asserts:

  • Every individual tag is ≤ 128 characters
  • The {{short-sha}} tag (11 chars) is present and correct in the output

All 35 tests pass:

Test Suites: 5 passed, 5 total
Tests:       35 passed, 35 total

Additional Notes

The fix is backward-compatible - single-tag templates behave identically to before (split by , produces one element, truncated as usual).

@nookyo nookyo requested a review from borislavr as a code owner March 16, 2026 14:41
@nookyo nookyo linked an issue Mar 16, 2026 that may be closed by this pull request
@github-actions github-actions bot added the bug Something isn't working label Mar 16, 2026
@nookyo nookyo moved this to In Progress in qubership-DevOps Mar 16, 2026
@nookyo nookyo merged commit 0980d58 into main Mar 16, 2026
31 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in qubership-DevOps Mar 16, 2026
@nookyo nookyo deleted the 654-bug-incorrect-tags-truncating-during-build branch March 16, 2026 14:44
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect tags truncating during build

2 participants