freckle / yesod-auth-oauth2

OAuth2 authentication for yesod
MIT License
71 stars 53 forks source link

Build failures with hoauth2-1.14.0? #135

Closed lf- closed 4 years ago

lf- commented 4 years ago

I am encountering a confusing issue building this library, apparently caused by a change in the hoauth2 API at some point since 1.8.3 (EDIT: changed in 1.9.0), where authGetBS used to return an IO (Either (OAuth2Error Value) ByteString) and now returns IO (Either ByteString ByteString). This breakage seems somewhat surprising given the message for https://github.com/thoughtbot/yesod-auth-oauth2/commit/0036d5f4e0e632e7ee757b6d1de8410ceee6f31f along with the latest changelog.

To reproduce: add this to the stack.yaml

extra-deps:
  - hoauth2-1.14.0

Failing:

[nix-shell:~/dev/yesod-auth-oauth2]$ stack ghci
Configuring GHCi with the following packages: yesod-auth-oauth2
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
[1 of 6] Compiling URI.ByteString.Extension ( /home/jade/dev/yesod-auth-oauth2/src/URI/ByteString/Extension.hs, interpreted )
[2 of 6] Compiling Yesod.Auth.OAuth2.ErrorResponse ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/ErrorResponse.hs, interpreted )
[3 of 6] Compiling Yesod.Auth.OAuth2.Exception ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Exception.hs, interpreted )
[4 of 6] Compiling Yesod.Auth.OAuth2.Dispatch ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Dispatch.hs, interpreted )
[5 of 6] Compiling Yesod.Auth.OAuth2 ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2.hs, interpreted )
[6 of 6] Compiling Yesod.Auth.OAuth2.Prelude ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Prelude.hs, interpreted )

/home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Prelude.hs:89:34: error:
    • Couldn't match type ‘BL.ByteString’ with ‘OAuth2Error Value’
      Expected type: IO (Either (OAuth2Error Value) BL.ByteString)
        Actual type: IO (Either BL.ByteString BL.ByteString)
    • In the second argument of ‘(=<<)’, namely
        ‘authGetBS manager (accessToken token) url’
      In a stmt of a 'do' block:
        resp <- fromAuthGet name
                  =<< authGetBS manager (accessToken token) url
      In the expression:
        do resp <- fromAuthGet name
                     =<< authGetBS manager (accessToken token) url
           decoded <- fromAuthJSON name resp
           pure (decoded, resp)
   |
89 |     resp <- fromAuthGet name =<< authGetBS manager (accessToken token) url
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, five modules loaded.
Loaded GHCi configuration from /tmp/jade/haskell-stack-ghci/77338fc5/ghci-script
*Yesod.Auth.OAuth2>
Leaving GHCi.

Working result from running stack repl without changing the hoauth2 version:

[nix-shell:~/dev/yesod-auth-oauth2]$ stack repl src/Yesod/Auth/OAuth2/Prelude.hs
Using configuration for yesod-auth-oauth2:lib to load /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Prelude.hs
Configuring GHCi with the following packages: yesod-auth-oauth2
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
[1 of 6] Compiling URI.ByteString.Extension ( /home/jade/dev/yesod-auth-oauth2/src/URI/ByteString/Extension.hs, interpreted )
[2 of 6] Compiling Yesod.Auth.OAuth2.ErrorResponse ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/ErrorResponse.hs, interpreted )
[3 of 6] Compiling Yesod.Auth.OAuth2.Exception ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Exception.hs, interpreted )
[4 of 6] Compiling Yesod.Auth.OAuth2.Dispatch ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Dispatch.hs, interpreted )
[5 of 6] Compiling Yesod.Auth.OAuth2 ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2.hs, interpreted )
[6 of 6] Compiling Yesod.Auth.OAuth2.Prelude ( /home/jade/dev/yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Prelude.hs, interpreted )
Ok, six modules loaded.
Loaded GHCi configuration from /tmp/jade/haskell-stack-ghci/77338fc5/ghci-script
*Yesod.Auth.OAuth2.Prelude> import Network.OAuth.OAuth2
*Yesod.Auth.OAuth2.Prelude Network.OAuth.OAuth2> :t authGetBS
authGetBS
  :: FromJSON err =>
     Manager
     -> AccessToken -> URI -> IO (OAuth2Result err BL.ByteString)
*Yesod.Auth.OAuth2.Prelude Network.OAuth.OAuth2>
pbrisbin commented 4 years ago

hoauth2 API at some point since 1.8.3 (EDIT: changed in 1.9.0), where authGetBS used to return...

I vaguely remember this, and I think it was the exact reason for the <1.9 bound before 0036d5f. I must've missed that the upper bound was also changing in that commit.

So, I think what your saying is that:

-    - hoauth2 >=1.3.0 && <1.9
+    - hoauth2 >=1.7.0 && <1.11

Should've been:

-    - hoauth2 >=1.3.0 && <1.9
+    - hoauth2 >=1.7.0 && <1.9

I'll tighten that back up now.

lf- commented 4 years ago

It would be nice to have support for a newer hoauth2 as 1.8.0 is fairly old.

pbrisbin commented 4 years ago

Yeah that's #137 , I just wanted to get the build fixed first.

andrewthad commented 4 years ago

Would you mind tightening the bound on hackage as well, either through a metadata revision or a patch release? I just ran into this issue as well.

pbrisbin commented 4 years ago

Ack, I'm sorry about this. I meant to do more things and forgot... I think it's all corrected now with a few releases:

andrewthad commented 4 years ago

Awesome, thanks!