3box / 3box-graphql

3box GraphQL Service
9 stars 0 forks source link

CORS issue when querying an address that doesn't have a profile. #20

Closed oed closed 5 years ago

oed commented 5 years ago

Reported in https://github.com/3box/3box-js/issues/240#issuecomment-454682517

marc4gov commented an hour ago Yeah, seems to work now. Strange things happen though with rinkeby, accounts with no 3box profile are still giving CORS issue, you would expect a different error message


oed commented 5 years ago

@zachferland @c-castillo Was this issue fixed?

zachferland commented 5 years ago

Not sure, I didn't follow original issue. But we should make sure that if graphql sends other responses besides 200s that they also all have the headers we need

oed commented 5 years ago

So I think what he meant is that if you call getProfile with an ethereum address that don't have a profile you get a CORS error.

c-castillo commented 5 years ago

Just solved one part of the issue, CORS error at any event. Still missing the CORS if there's no profile (it should return a 404). I assigned the issue to myself.

oed commented 5 years ago

great, ty!

laurentsenta commented 5 years ago

Hi there, I'm looking into this as I get to know the codebase, could we recap the issue?

I don't see CORS errors when I query an address without profile:

    fetch('https://aic67onptg.execute-api.us-west-2.amazonaws.com/develop/graphql',
      {
        method: "POST", headers: {'Content-Type': 'application/json'},
        body: JSON.stringify({"query": "{ profile(id: \"0xe3b281f3dd2b87c7b3eacc0402a4fd7d827f2955\") { name } }"})
      })
      .then(x => console.error("X=", x, "JSON=", x.json().then(console.error)))
oed commented 5 years ago

@lsenta what do you get instead? An empty profile?

laurentsenta commented 5 years ago

@oed yes, I get a result with no profile and an errors array. If that's expected I'd say we can close this ticket.

{
  "errors": [
    {
      "message": "404: Not Found",
      "locations": [
        {
          "line": 1,
          "column": 3
        }
      ],
      "path": [
        "profile"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "response": {
          "url": "https://ipfs.3box.io/profile?address=0xe3b281f3dd2b87c7b3eacc0402a4fd7d827f2955",
          "status": 404,
          "statusText": "Not Found",
          "body": {
            "status": "error",
            "message": "Address link not found, address does not have a 3Box or is malformed"
          }
        },
        "exception": {
          "stacktrace": [
            "Error: 404: Not Found",
            "    at ProfileAPI.<anonymous> (/var/task/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:79:25)",
            "    at Generator.next (<anonymous>)",
            "    at /var/task/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:7:71",
            "    at new Promise (<anonymous>)",
            "    at __awaiter (/var/task/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:3:12)",
            "    at ProfileAPI.errorFromResponse (/var/task/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:69:16)",
            "    at ProfileAPI.<anonymous> (/var/task/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:50:34)",
            "    at Generator.next (<anonymous>)",
            "    at /var/task/node_modules/apollo-datasource-rest/dist/RESTDataSource.js:7:71",
            "    at new Promise (<anonymous>)"
          ]
        }
      }
    }
  ],
  "data": {
    "profile": null
  }
}
oed commented 5 years ago

Ok, then I guess we can close this 👍