Unable to update schema via /admin/schema

Attempting to update the schema via CURL fails with {"errors":[{"message":"resolving updateGQLSchema failed because No connection exists (Locations: [{Line: 3, Column: 4}])","extensions":{"code":"Error"}}]}

Version: shuri



    image: dgraph/dgraph:shuri
      - /tmp/data:/dgraph
      - 5080:5080
      - 6080:6080
    restart: on-failure
    command: dgraph zero --my=zero:5080
    image: dgraph/dgraph:shuri
      - /tmp/data:/dgraph
      - 8080:8080
      - 9080:9080
    restart: on-failure
    command: dgraph alpha --my=alpha:7080 --lru_mb=2048 --zero=zero:5080 --whitelist=

Note the whitelist flag for alpha

Command to update schema:

curl -v -X POST localhost:8080/admin/schema -d '@./schema.graphql'
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /admin/schema HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 17194
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Headers: X-Dgraph-AccessToken, Content-Type, Content-Length, Accept-Encoding, Cache-Control, X-CSRF-Token, X-Auth-Token, X-Requested-With
< Access-Control-Allow-Methods: POST, OPTIONS
< Access-Control-Allow-Origin: *
< Connection: close
< Content-Type: application/json
< Date: Mon, 14 Sep 2020 19:38:48 GMT
< Content-Length: 154
* Closing connection 0
{"errors":[{"message":"resolving updateGQLSchema failed because No connection exists (Locations: [{Line: 3, Column: 4}])","extensions":{"code":"Error"}}]}

As per this post: Authentication for admin endpoints, I have set the whitelist flag for the alpha.

This worked at my side

curl --request POST \
  --url http://localhost:8080/admin/schema \
  --header 'content-type: application/octet-stream' \  # This header  isn't needed
  --data  someDataHere

This is exported from Insomnia.

Thanks @MichelDiz. That header didn’t change the behavior.

Can you post your Docker setup?

Actually wait, I think I found the problem. I was mounting dgraph’s data directory to my local /tmp. Changing this mount to another location (~/dgraph/data, for instance) enabled me to upload the schema via /admin/schema.

Seems as though however the error message returned should be more forthcoming…