fix: guard against reserved output name collisions

Address review feedback:
- Skip setting individual outputs for reserved names (cache-hit, versions)
- Emit warning when a tool name conflicts with reserved outputs
- Document dynamic outputs pattern in action.yml comments
This commit is contained in:
Jorge Rodriguez 2026-04-21 15:14:32 +02:00
parent 3ae98ac76a
commit 1aec2f5751
No known key found for this signature in database
GPG key ID: A22D46F0D97D588A
4 changed files with 24 additions and 3 deletions

View file

@ -90,6 +90,9 @@ outputs:
description: A boolean value to indicate if a cache was hit.
versions:
description: JSON object containing all active tool versions with metadata (version, requested_version, install_path, source).
# Dynamic outputs: each active tool (e.g. `node`, `bun`, `python`) is also
# set as an individual output whose value is the resolved version string.
# Access via ${{ steps.<step-id>.outputs.<tool-name> }}
runs:
using: node24
main: dist/index.js

10
dist/index.js generated vendored
View file

@ -84932,11 +84932,19 @@ async function outputToolVersions() {
});
const tools = JSON.parse(output.stdout);
const activeVersions = {};
// Reserved output names that should not be overwritten by tool names
const reservedOutputs = ['cache-hit', 'versions'];
for (const [toolName, versions] of Object.entries(tools)) {
const activeVersion = versions.find(v => v.active);
if (activeVersion) {
// Set individual output: steps.mise.outputs.bun = "1.0.0"
setOutput(toolName, activeVersion.version);
// Skip reserved output names to avoid conflicts
if (reservedOutputs.includes(toolName)) {
warning(`Tool "${toolName}" conflicts with reserved output name; skipping individual output for this tool.`);
}
else {
setOutput(toolName, activeVersion.version);
}
info(`${toolName}: ${activeVersion.version}`);
// Collect for JSON output with full metadata
activeVersions[toolName] = {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -169,11 +169,21 @@ async function outputToolVersions(): Promise<void> {
const tools: Record<string, ToolInfo[]> = JSON.parse(output.stdout)
const activeVersions: Record<string, ToolVersionOutput> = {}
// Reserved output names that should not be overwritten by tool names
const reservedOutputs = ['cache-hit', 'versions']
for (const [toolName, versions] of Object.entries(tools)) {
const activeVersion = versions.find(v => v.active)
if (activeVersion) {
// Set individual output: steps.mise.outputs.bun = "1.0.0"
core.setOutput(toolName, activeVersion.version)
// Skip reserved output names to avoid conflicts
if (reservedOutputs.includes(toolName)) {
core.warning(
`Tool "${toolName}" conflicts with reserved output name; skipping individual output for this tool.`
)
} else {
core.setOutput(toolName, activeVersion.version)
}
core.info(`${toolName}: ${activeVersion.version}`)
// Collect for JSON output with full metadata