fix: rewrite parse_reference without if-then-else (unsupported in yq v4)

The previous expression used `if ($r | type) == "!!str" then ... end`
which produces a lexer error in yq v4.50–v4.53. This caused every
parse_reference call to return empty output, silently skipping all
references — the root cause of the missing [INFO] messages and tree.

Replace with a single-line expression using only the // alternative
operator and select(), which work across all tested yq v4 versions:

  .references[N] | (.url // .) + "|" + (.into // "") + "|" +
  (.ref // "") + "|" +
  ((.env | select(tag == "!!seq") | join(",")) // .env // "")

.url // . handles both string refs (no .url key) and object refs.
env arrays are joined; null env falls back to "".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 23:18:24 +02:00
parent d2bff00ee2
commit 363e126914
+4 -14
View File
@@ -282,20 +282,10 @@ parse_reference() {
local config_file="$1" local config_file="$1"
local ref_index="$2" local ref_index="$2"
# Single yq call for all fields — multiple calls per reference were flooding # Single yq call using only // and select — if-then-else is not supported in
# the process table on hosts with low ulimit -u (e.g. IONOS shared hosting), # all yq v4 builds. .url//. handles both string refs (no .url key) and object
# causing intermittent empty 'into' values and wrong install locations. # refs. env array is joined; null env falls back to empty string.
yq eval " yq eval ".references[$ref_index] | (.url // .) + \"|\" + (.into // \"\") + \"|\" + (.ref // \"\") + \"|\" + ((.env | select(tag == \"!!seq\") | join(\",\")) // .env // \"\")" "$config_file" 2>/dev/null
.references[$ref_index] as \$r |
if (\$r | type) == \"!!str\" then
\$r + \"|||\"
else
((\$r.url // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
((\$r.into // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
((\$r.ref // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
(\$r.env | if . == null then \"\" elif type == \"!!seq\" then join(\",\") else (. | if . == \"null\" then \"\" else . end) end)
end
" "$config_file" 2>/dev/null
} }
# Check if current environment matches the filter # Check if current environment matches the filter