Skip to content

fix(compute): ensure trailing newline in fetched discovery doc - #16407

Merged
colinmoy merged 2 commits into
googleapis:mainfrom
colinmoy:fix-compute-discovery-trailing-newline
Sep 2, 2026
Merged

fix(compute): ensure trailing newline in fetched discovery doc#16407
colinmoy merged 2 commits into
googleapis:mainfrom
colinmoy:fix-compute-discovery-trailing-newline

Conversation

@colinmoy

@colinmoy colinmoy commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes a failure encountered during the scheduled run of the .github/workflows/update-compute-discovery.yml automation workflow.

@colinmoy
colinmoy requested a review from a team as a code owner September 1, 2026 22:53
@product-auto-label product-auto-label Bot added the api: compute Issues related to the Compute Engine API. label Sep 1, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the update_discovery_doc.sh script to ensure that the fetched discovery document ends with a trailing newline. The review feedback suggests improving portability by separating the option and argument in the tail command (using tail -c 1 instead of tail -c1) and simplifying the echo command used to append the newline.

Comment on lines +105 to +107
if [[ -s "${TEMP_JSON}" && -n "$(tail -c1 "${TEMP_JSON}")" ]]; then
echo "" >>"${TEMP_JSON}"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better portability across different POSIX-compliant environments (such as BSD/macOS and various Linux distributions), it is recommended to separate the option and its argument with a space (i.e., tail -c 1 instead of tail -c1). Additionally, echo without arguments can be used instead of echo "" to append a newline.

Suggested change
if [[ -s "${TEMP_JSON}" && -n "$(tail -c1 "${TEMP_JSON}")" ]]; then
echo "" >>"${TEMP_JSON}"
fi
if [[ -s "${TEMP_JSON}" && -n "$(tail -c 1 "${TEMP_JSON}")" ]]; then
echo >>"${TEMP_JSON}"
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (fd8e805) to head (697794b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16407   +/-   ##
=======================================
  Coverage   92.24%   92.24%           
=======================================
  Files        2246     2246           
  Lines      212296   212296           
=======================================
+ Hits       195825   195840   +15     
+ Misses      16471    16456   -15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@colinmoy
colinmoy merged commit 132629c into googleapis:main Sep 2, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: compute Issues related to the Compute Engine API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants