BUILD-10503 Sanitize workflow name in cache keys#224
Conversation
ca06b8e to
57296e8
Compare
57296e8 to
b1aef21
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
b1aef21 to
6afc22b
Compare
SonarQube reviewer guideSummary: Sanitize workflow names in cache keys across all package manager actions to replace spaces with hyphens, ensuring valid cache key formatting. Review Focus: Verify that the sanitization logic ( Start review at:
|




Problem
Spaces in GitHub workflow names cause cache save/restore failures. The workflow name is included in the S3 cache key, and spaces in the key result in malformed pre-signed URLs — the request hits an error response instead of the actual S3 object, which doesn't support HTTP range requests:
Fix
Added a sanitize step before each cache step that replaces spaces in the workflow name with
-before it is used in the cache key. The step uses an explicitWORKFLOW_NAMEenv var sourced fromgithub.workflow(rather than$GITHUB_WORKFLOW) to ensure the value is consistent with what would have been interpolated directly.All four actions use the same pattern: the sanitize step outputs
workflow_name, which is then referenced directly in thekey:andrestore-keys:expressions of the cache step. For actions where the resultingkey:line exceeds the 140-character yamllint limit (config-maven,config-pip), a# yamllint disable/enable rule:line-lengthblock is used.Changes
config-npm/action.yml— sanitize workflow name in NPM cache keyconfig-maven/action.yml— sanitize workflow name in Maven cache keyconfig-gradle/action.yml— sanitize workflow name in Gradle cache keyconfig-pip/action.yml— sanitize workflow name in Pip cache keyJira
https://sonarsource.atlassian.net/browse/BUILD-10503
Testing
https://github.com/SonarSource/sonar-dummy/actions/runs/22349083633/job/64671224433#step:4:740 after
https://github.com/SonarSource/sonar-dummy/actions/runs/22348992658/job/64670914225#step:4:717 before