From 5824f679bb9aaafa9a71d0efd4754d92b7bdc3ca Mon Sep 17 00:00:00 2001 From: Colin Moy Date: Tue, 1 Sep 2026 22:46:41 +0000 Subject: [PATCH 1/2] fix(compute): ensure trailing newline in fetched discovery doc --- generator/discovery/update_discovery_doc.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/generator/discovery/update_discovery_doc.sh b/generator/discovery/update_discovery_doc.sh index b6f19e847dcd5..a49126772626d 100755 --- a/generator/discovery/update_discovery_doc.sh +++ b/generator/discovery/update_discovery_doc.sh @@ -101,6 +101,11 @@ if ! curl -fsSL "${COMPUTE_DISCOVERY_DOCUMENT_URL}" >"${TEMP_JSON}"; then exit 1 fi +# Ensure the discovery document ends with a trailing newline. +if [[ -s "${TEMP_JSON}" && -n "$(tail -c1 "${TEMP_JSON}")" ]]; then + echo "" >>"${TEMP_JSON}" +fi + REVISION=$(sed -En 's/ \"revision\": \"([[:digit:]]+)\",/\1/p' "${TEMP_JSON}") if [[ -z "${REVISION}" ]]; then io::log_red "Could not parse revision from fetched discovery document." From 697794bc5825eac55c66c9b08339f957366188c3 Mon Sep 17 00:00:00 2001 From: Colin Moy Date: Tue, 1 Sep 2026 22:55:41 +0000 Subject: [PATCH 2/2] refactor(compute): improve portability of trailing newline check --- generator/discovery/update_discovery_doc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generator/discovery/update_discovery_doc.sh b/generator/discovery/update_discovery_doc.sh index a49126772626d..499a232ddbb8c 100755 --- a/generator/discovery/update_discovery_doc.sh +++ b/generator/discovery/update_discovery_doc.sh @@ -102,8 +102,8 @@ if ! curl -fsSL "${COMPUTE_DISCOVERY_DOCUMENT_URL}" >"${TEMP_JSON}"; then fi # Ensure the discovery document ends with a trailing newline. -if [[ -s "${TEMP_JSON}" && -n "$(tail -c1 "${TEMP_JSON}")" ]]; then - echo "" >>"${TEMP_JSON}" +if [[ -s "${TEMP_JSON}" && -n "$(tail -c 1 "${TEMP_JSON}")" ]]; then + echo >>"${TEMP_JSON}" fi REVISION=$(sed -En 's/ \"revision\": \"([[:digit:]]+)\",/\1/p' "${TEMP_JSON}")