Skip to content

Prevent unhandled exception when running via schedule #69

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

Merged
merged 2 commits into from
Apr 19, 2021
Merged

Prevent unhandled exception when running via schedule #69

merged 2 commits into from
Apr 19, 2021

Conversation

mcbanderson
Copy link
Contributor

Resolves #68

pull-request.py Outdated
@@ -395,7 +395,10 @@ def main():
print("PULL_REQUEST_FROM_BRANCH is not set, checking branch in payload.")
with open(check_events_json(), "r") as fd:
from_branch = json.loads(fd.read()).get("ref")
Copy link
Owner

Choose a reason for hiding this comment

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

Thank you for catching this! A question about your choice of fix - why not just do:

Suggested change
from_branch = json.loads(fd.read()).get("ref")
from_branch = json.loads(fd.read()).get("ref", "")

And avoid the extra try / except and exception? The result of the above is an empty string, which won't trigger the error, and will cleanly exit in the next block telling the user to set the envar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, that is cleaner. Updating now

Copy link
Owner

@vsoch vsoch left a comment

Choose a reason for hiding this comment

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

Perfect! Let me get this merged and released as a version so you can use it asap. Thank you again!

@vsoch vsoch merged commit e2a437c into vsoch:master Apr 19, 2021
@mcbanderson
Copy link
Contributor Author

Happy to help, thanks for the quick response and merge! There's no need to cut a new release just for this (unless that's your usual workflow). Either way I needed to update my Workflow to utilize PULL_REQUEST_FROM_BRANCH, which I've already done

@vsoch
Copy link
Owner

vsoch commented Apr 19, 2021

I'm of the mindset to release often, so it's my preference to do a quick release. You should be good to go without it, but for provenance in this discussion, I'll link it here: https://github.com/vsoch/pull-request-action/releases/tag/1.0.16. Happy coding! <3

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

Successfully merging this pull request may close these issues.

Error when triggering via a Schedule event
2 participants