Skip to content

[#61]: evPushSender can be null#60

Merged
kvanbere merged 1 commit intocuedo:developfrom
hercules-ci:evPushSender-optional
Dec 13, 2022
Merged

[#61]: evPushSender can be null#60
kvanbere merged 1 commit intocuedo:developfrom
hercules-ci:evPushSender-optional

Conversation

@roberth
Copy link
Copy Markdown
Contributor

@roberth roberth commented Dec 6, 2022

Issue reference:

Fixes #61
GitHub sometimes sends a pull event without a sender. See the anonymized test case.

Submission Checklist:

  • Have you followed the guidelines in our Contributing document (for example, is your tree a clean merge)?
    • Broken link
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Does your submission build?
    • built on linux with haskell.nix
  • Does your submission pass tests?
  • Have you run lints on your code locally prior to submission?
  • Have you updated all of the cabal/nix infrastructure?
  • Is this a breaking change? Have you discussed this?
    • Formally it is a breaking change, as PushEvent consumers may have to handle a Nothing, but this merely reflects the reality of github webhooks. sender may be omitted in rare cases.

@kvanbere
Copy link
Copy Markdown
Member

Hi Robert, thanks for the PR!

I'm currently away, but I'll take a look and get back to you within the next day or so.

@kvanbere kvanbere added the bug label Dec 11, 2022
@kvanbere kvanbere self-requested a review December 11, 2022 22:09
@kvanbere kvanbere added this to the 0.17.0 milestone Dec 11, 2022
@kvanbere
Copy link
Copy Markdown
Member

@roberth Changes look good, but I want to run the CI over this. I have to make a few changes so that it can be run on a remote fork since the GitHub push event does not trigger due to the way this was raised.

Comment thread spec/DecodeEventsSpec.hs Outdated
Copy link
Copy Markdown
Member

@kvanbere kvanbere left a comment

Choose a reason for hiding this comment

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

See inline comment on CI failure for mempty.

@kvanbere kvanbere changed the title evPushSender can be null [#61]: evPushSender can be null Dec 12, 2022
@kvanbere kvanbere linked an issue Dec 12, 2022 that may be closed by this pull request
@roberth roberth force-pushed the evPushSender-optional branch from fe99204 to 2f149c1 Compare December 12, 2022 23:47
Copy link
Copy Markdown
Member

@kvanbere kvanbere left a comment

Choose a reason for hiding this comment

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

Looks like the CI has raised warnings that we forgot to export EventHasMaybeSender(..).

@roberth roberth force-pushed the evPushSender-optional branch from 2f149c1 to 23b9bbe Compare December 13, 2022 00:28
@roberth roberth requested a review from kvanbere December 13, 2022 00:28
Copy link
Copy Markdown
Member

@kvanbere kvanbere left a comment

Choose a reason for hiding this comment

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

Hi Rob, thanks for that revision. According to CI, it looks like one of the examples (github-webhooks-servant-example) needs to be updated to match this change to the API:

2022-12-13T00:51:21.1290270Z github-webhooks-servant-example       > Configuring github-webhooks-servant-example-0.0.0...
2022-12-13T00:51:21.3253306Z github-webhooks-servant-simple-example> configure (exe)
2022-12-13T00:51:21.3257387Z github-webhooks-servant-example       > build (exe)
2022-12-13T00:51:21.4035215Z github-webhooks-servant-example       > Preprocessing executable 'github-webhooks-servant-example' for github-webhooks-servant-example-0.0.0..
2022-12-13T00:51:21.4036052Z github-webhooks-servant-example       > Building executable 'github-webhooks-servant-example' for github-webhooks-servant-example-0.0.0..
2022-12-13T00:51:21.5255894Z github-webhooks-servant-example       > [1 of 2] Compiling Main
2022-12-13T00:51:21.9723780Z github-webhooks-servant-simple-example> Configuring github-webhooks-servant-simple-example-0.0.0...
2022-12-13T00:51:22.0500611Z github-webhooks-servant-example       > 
2022-12-13T00:51:22.0502246Z github-webhooks-servant-example       > /home/runner/work/github-webhooks/github-webhooks/examples/servant/src/Main.hs:38:38: error:
2022-12-13T00:51:22.0502986Z github-webhooks-servant-example       >     • Couldn't match type ‘Maybe HookUser’ with ‘HookUser’
2022-12-13T00:51:22.0503531Z github-webhooks-servant-example       >       Expected type: PushEvent -> HookUser
2022-12-13T00:51:22.0504386Z github-webhooks-servant-example       >         Actual type: PushEvent -> Maybe HookUser
2022-12-13T00:51:22.0504908Z github-webhooks-servant-example       >     • In the second argument of ‘(.)’, namely ‘evPushSender’
2022-12-13T00:51:22.0505409Z github-webhooks-servant-example       >       In the second argument of ‘(.)’, namely
2022-12-13T00:51:22.0505871Z github-webhooks-servant-example       >         ‘whUserLogin . evPushSender’
2022-12-13T00:51:22.0506373Z github-webhooks-servant-example       >       In the expression: show . whUserLogin . evPushSender
2022-12-13T00:51:22.0506787Z github-webhooks-servant-example       >    |
2022-12-13T00:51:22.0507361Z github-webhooks-servant-example       > 38 |     putStrLn $ (show . whUserLogin . evPushSender) ev ++ " pushed a commit causing HEAD SHA to become:"
2022-12-13T00:51:22.0507911Z github-webhooks-servant-example       >    |  

https://github.com/cuedo/github-webhooks/actions/runs/3681095902/jobs/6227414754

The examples are designed to be overly-simple, so I think using fromJust would be fine here.

This is very rare, so to keep the example simple, it uses fromJust.
@roberth roberth force-pushed the evPushSender-optional branch from 23b9bbe to ebb3af2 Compare December 13, 2022 01:07
@roberth roberth requested a review from kvanbere December 13, 2022 02:10
@kvanbere kvanbere merged commit d028bba into cuedo:develop Dec 13, 2022
@roberth
Copy link
Copy Markdown
Contributor Author

roberth commented Dec 13, 2022

Thanks for helping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub sometimes sends a pull event without a sender

2 participants