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

Mutate: rpc error: code = Unknown desc = Empty query #82

Closed
jawr opened this issue Aug 24, 2019 · 2 comments

Comments

@jawr
Copy link

commented Aug 24, 2019

Hi there!

I have been trying to play with Dgraph but am having issues inserting data. I am using docker-compose as described in 'Get started'. Following examples using curl for setting and retrieving data work.

Here is the relevant code below:

type Record struct {
        Uid string `json:"uid,omitempty"`
        Name string `json:"name,omitempty"`
        Type uint16 `json:"type,omitempty"`
        Class uint16 `json:"class,omitempty"`
        Ttl uint32 `json:"ttl,omitempty"`
        Original string  `json:"original,omitempty"`
}

func addRecord(client *dgo.Dgraph, rr dns.RR) error {
        var record Record

        record.Name = header.Name
        record.Type = header.Rrtype
        record.Class = header.Class
        record.Ttl = header.Ttl
        record.Original = header.String()

        ctx := context.Background()

        data, err := json.Marshal(record)
        if err != nil {
                return errors.Wrap(err, "Marshal")
        }

        mu := &api.Mutation{
                CommitNow: true,
                SetJson: data,
        }

        tx := client.NewTxn()
        defer tx.Discard(ctx)

        log.Printf("%+v", mu)
       // prints: set_json:"{\"name\":\"COM.\",\"type\":2,\"class\":1,\"ttl\":172800,\"original\":\"COM.\\t172800\\tIN\\tNS\\t\"}" commit_now:true

        _, err = tx.Mutate(ctx, mu)
        if err != nil {
                return errors.Wrap(err, "Mutate")
                // err == "rpc error: code = Unknown desc = Empty query"
        }

        err = tx.Commit(ctx)
        if err != nil {
                return errors.Wrap(err, "Commit")
        }

        return nil
}

the output for this is:

2019/08/24 15:31:43 set_json:"{\"name\":\"COM.\",\"type\":2,\"class\":1,\"ttl\":172800,\"original\":\"COM.\\t172800\\tIN\\tNS\\t\"}" commit_now:true 
2019/08/24 15:31:43 Error in add record at count 2: Mutate: rpc error: code = Unknown desc = Empty query

Thank you for your time.

@bgv

This comment has been minimized.

Copy link

commented Aug 24, 2019

Which versions of dgraph and dgo are you running?

I had the same problem with dgraph v1.1.0-rc1 and when tried using it with dgo v2.

Try using dgraph v1.1.0-rc2 with github.com/dgraph-io/dgo/v2 otherwise use dgraph v1.1.0-rc1 with github.com/dgraph-io/dgo only.

@jawr

This comment has been minimized.

Copy link
Author

commented Aug 25, 2019

The version mismatch was exactly it, thank you for the help @bgv !

@jawr jawr closed this Aug 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.