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

gogol-datastore missing colon in request #33

Closed
MaxDaten opened this issue Jul 26, 2016 · 1 comment
Closed

gogol-datastore missing colon in request #33

MaxDaten opened this issue Jul 26, 2016 · 1 comment
Assignees
Labels

Comments

@MaxDaten
Copy link

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
Copy link
Owner

Thanks for looking into it and providing the workaround. I'll fix it in the library proper shortly.

@brendanhay brendanhay self-assigned this Jul 26, 2016
@brendanhay brendanhay added the bug label Jul 26, 2016
brendanhay added a commit that referenced this issue Aug 10, 2016
For example, CaptureMode "projectId" "commit" being
incorrectly serialised to "projectIdcommit" instead
of "projectId:commit".

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

No branches or pull requests

2 participants