gogol-datastore missing colon in request
Closed this issue · 1 comments
MaxDaten commented
I'm currently experimenting with the gogol-datastore library, and experienced an bug. Here my example code:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.Google as Google
import Network.Google.Datastore
import Control.Lens
import System.IO (stdout)
import Control.Monad.Trans (liftIO)
main = do
let papegoPartition = partitionId & piProjectId ?~ "my-project-id" & piNamespaceId ?~ "dev"
logger <- Google.newLogger Google.Debug stdout
env <- Google.newEnv <&> (Google.envLogger .~ logger) . Google.allow datastoreScope
let proofId = key
& kPartitionId ?~ papegoPartition
& kPath .~ [pathElement & peKind ?~ "Proof" & peName ?~ "proof_abc"]
proofEntity = entity
& eKey ?~ proofId
putStrLn "Entity:"
print proofEntity
let upsertProof = commitRequest
& crMutations .~ [mutation & mUpsert ?~ proofEntity]
& crMode ?~ NonTransactional
print upsertProof
runResourceT . runGoogle env $ do
resp <- Google.send (projectsCommit upsertProof "my-project-id")
liftIO $ print resp
putStrLn "Done!"
Results into a 404 with this debug output:
[Client Request] {
host = datastore.googleapis.com:443
secure = True
method = POST
timeout = Just 70000000
redirects = 10
path = /v1beta3/projects/my-project-idcommit
query = ?pp=true&alt=json
headers = authorization: Bearer XXX; accept: application/json; content-type: application/json
body = {"mutations":[{"upsert":{"key":{"partitionId":{"namespaceId":"dev","projectId":"my-project-id"},"path":[{"kind":"Proof","name":"proof_abc"}]}}}],"mode":"NON_TRANSACTIONAL"}
}
[Client Response] {
status = 404 Not Found
headers = date: Tue, 26 Jul 2016 13:29:12 GMT; content-type: text/html; charset=UTF-8; server: ESF; content-length: 1616; x-xss-protection: 1; mode=block; x-frame-options: SAMEORIGIN; x-content-type-options: nosniff; alternate-protocol: 443:quic; alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30,29,28,27,26,25"
}
The Problem is the path: /v1beta3/projects/my-project-idcommit
which should be /v1beta3/projects/my-project-id:commit
(see REST-API Reference)
Changing
resp <- Google.send (projectsCommit upsertProof "my-project-id")
to
resp <- Google.send (projectsCommit upsertProof "my-project-id:")
solves it as quick workaround.
brendanhay commented
Thanks for looking into it and providing the workaround. I'll fix it in the library proper shortly.