Skip to content

Conversation

@glasnt
Copy link
Contributor

@glasnt glasnt commented Mar 24, 2025

Description

Identified in https://github.com/GoogleCloudPlatform/nodejs-docs-samples/pull/3985/files#diff-86f605e760c2507e13cf901bc344431a78deb5dbd16c6e94726a76affe9a9bb1R62

Ensures all copies of retry.sh use the correct exit code to correctly fail when retries exceeded.

  • Please merge this PR for me once it is approved

@glasnt glasnt requested review from a team as code owners March 24, 2025 22:11
@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: run Issues related to the Cloud Run API. asset: pattern DEE Asset tagging - Pattern. labels Mar 24, 2025
Copy link
Contributor

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

Choose a reason for hiding this comment

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

Hello @glasnt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request addresses an issue where the retry.sh script was not exiting with a non-zero exit code when the maximum number of retries was exceeded. This could lead to incorrect behavior in automated systems that rely on the exit code to determine the success or failure of a command. To fix this, I've updated the retry.sh script in two different directories to explicitly exit with code 1 when the maximum number of retries is reached.

Highlights

  • Bug Fix: Ensures retry.sh script exits with a non-zero exit code (1) when retries are exhausted.
  • Improved Reliability: Corrects the exit behavior of retry.sh to properly signal failures in automated processes.

Changelog

  • run/markdown-preview/editor/test/retry.sh
    • Modified the script to exit with code 1 when the maximum number of retries is reached. Specifically, line 62 was changed from exit to exit 1.
  • run/markdown-preview/renderer/test/retry.sh
    • Modified the script to exit with code 1 when the maximum number of retries is reached. Specifically, line 62 was changed from exit to exit 1.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Did you know?

The #!/bin/sh shebang line at the beginning of a shell script tells the operating system which interpreter to use to execute the script. It's not just for sh; you can use #!/usr/bin/python3 or #!/usr/bin/env node for Python or Node.js scripts, respectively.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 ensures that the retry.sh script exits with a non-zero exit code when the maximum number of retries is exceeded. This is crucial for proper error handling in automated scripts and build pipelines. The change is straightforward and addresses the identified issue.

Merge Readiness

The changes are simple and effective in addressing the identified issue. The pull request is ready to be merged, as it ensures correct error handling in the retry.sh script. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging.

Comment on lines 61 to 62
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
exit
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Adding exit 1 here ensures that the script returns a failure status when all retries are exhausted. This is important for signaling to calling scripts that the operation failed after multiple attempts.

Consider adding a comment explaining why exit 1 is used here for clarity.

Suggested change
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
exit
exit 1
exit 1 # Exit with a non-zero status code to indicate failure after max retries

Comment on lines 61 to 62
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
exit
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the other retry.sh file, adding exit 1 here is essential for proper error signaling. A non-zero exit code indicates that the retried operation ultimately failed.

Consider adding a comment explaining why exit 1 is used here for clarity.

Suggested change
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
exit
exit 1
exit 1 # Exit with a non-zero status code to indicate failure after max retries

Copy link
Contributor

@iennae iennae left a comment

Choose a reason for hiding this comment

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

noticing linting is failing for unchanged files; is that intentional behavior?

@davidcavazos
Copy link

davidcavazos commented Mar 25, 2025

It's running lint on the entire changed packages. Looks like both run/markdown-preview/editor and run/markdown-preview/renderer were affected, so the linter ran on both of those packages. It seems like those packages had linter issues to begin with.

The previous linter ran gts lint fix first and then ran the linter, so all the automatically fixable lint issues were hidden. So a lot of packages actually have lint issues, it's just that the previous linter basically ignored them.

We can bring back the behavior of lint fix first, but those fixes will not get merged, they will just mask actual existing issues before actually checking. It might be easier to just run npx gts lint --fix on each of the affected package directories.

@glasnt glasnt merged commit 7ac230e into main Mar 26, 2025
13 checks passed
@glasnt glasnt deleted the exit1 branch March 26, 2025 00:51
rudrakhsha-crest pushed a commit to rudrakhsha-crest/nodejs-docs-samples that referenced this pull request Apr 18, 2025
* fix: ensure all retry.sh failures fail exit 1

* auto format

* Format Document

* revert Format Document (does not match gts)

* manual gts lint

---------

Co-authored-by: Jennifer Davis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: run Issues related to the Cloud Run API. asset: pattern DEE Asset tagging - Pattern. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants