Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idempotent Workflow Bug: OpenPrFunction Not Opening Pull Request after CompressImagesFunction Failure #1317

Open
NullPointer4096 opened this issue Apr 14, 2023 · 0 comments

Comments

@NullPointer4096
Copy link

NullPointer4096 commented Apr 14, 2023

In the current ImgBot workflow, there's an issue that prevents a pull request from being opened or updated in the downstream OpenPrFunction when there's a failure at the CompressImagesFunction, after it creates the ImgBot branch but before it sends an OpenPrMessage. This can happen if the function host encounters an error such as network, software, or hardware issues.

Steps to reproduce:

  1. The bot-controlled ImgBot branch has yet to be created or has been deleted after a successful merge.
  2. A git push to the bot-monitored branch (e.g., main) triggers the CompressImagesFunction through RouterFunction.
  3. CompressImagesFunction compresses the images on the main branch and creates the ImgBot branch as usual.
  4. Before sending a message to invoke the downstream OpenPrFunction, the underlying function host encounters an error. This can be simulated through breakpoints or throwing an exception.
  5. When CompressImagesFunction is retried, the boolean variable branchExists is set to true, because the ImgBot branch was created at the first execution.
  6. This variable makes OpenPrMessage.Update also to true. So later when OpenPrFunction is invoked, it seeks an existing open pull request to update but cannot find any, resulting in an exception.

Expected behavior:
OpenPrFunction should be able to create a new pull request or update an existing one based on the existence of an open pull request, without relying on the branchExists variable passed from upstream.

Actual behavior:
An exception is thrown, causing unsuccessful retries of the OpenPrFunction until the triggering message reaches the max retry count. To resolve this issue, the ImgBot branch must be deleted, and the CompressImagesFunction must be triggered again to start a new workflow withbranchExists = false.

Suggested fix:
Modify OpenPrFunction to determine whether it should create a pull request or update an existing one based on the existence of an open pull request, rather than relying on a variable passed from upstream; CompressImagesFunction should pass the repository information to the downstream OpenPrFunction without dictating whether the operation is an update or create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant