question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JWT Authorization Error: operator does not exist: uuid = integer

See original GitHub issue

Hasura Version: v1.0.0-alpha42

I am seeing the following error when trying to implement JWT Authorization:

  detail: {
   detail: {
    error: {
     code:  "postgres-error"      
     error:  "postgres query error"      
     internal: {
      arguments: [0]       
      error: {
       description:  null        
       exec_status:  "FatalError"        
       hint:  "No operator matches the given name and argument types. You might need to add explicit type casts."        
       message:  "operator does not exist: uuid = integer"        
       status_code:  "42883"        
      }
      prepared:  true       
      statement:  "SELECT  coalesce(json_agg("root" ), '[]' ) AS "root" FROM  (SELECT  row_to_json((SELECT  "_1_e"  FROM  (SELECT  "_0_root.base"."created_on" AS "created_on", "_0_root.base"."owner_id" AS "owner_id", "_0_root.base"."tabletop_id" AS "tabletop_id", "_0_root.base"."tabletop_name" AS "tabletop_name", "_0_root.base"."updated_on" AS "updated_on"       ) AS "_1_e"      ) ) AS "root" FROM  (SELECT  *  FROM "dt_public"."tabletop"  WHERE ((("dt_public"."tabletop"."owner_id") = (((current_setting('hasura.user')::json->>'x-hasura-test'))::integer)) OR ((("dt_public"."tabletop"."owner_id") IS NULL) AND ((((current_setting('hasura.user')::json->>'x-hasura-test'))::integer) IS NULL)))     ) AS "_0_root.base"      ) AS "_2_root"      "       
     }
     path:  "$"      
    }
    request:  "{"query":"{\n  dt_public_tabletop {\n    created_on\n    owner_id\n    tabletop_id\n    tabletop_name\n    updated_on\n  }\n}\n","variables":null}"     
   }

The JWT contains the following claim:

  "https://hasura.io/jwt/claims": {
    "x-hasura-default-role": "user",
    "X-Hasura-test": "adedb95e-47ad-43f5-b165-a9de4e406bd7",
    "x-hasura-allowed-roles": [
      "user"
    ]
  },

My postgresql table schema is the following:

CREATE TABLE IF NOT EXISTS dt.dt_public.tabletop
(
  tabletop_id   uuid DEFAULT gen_random_uuid(),
  tabletop_name VARCHAR(50) NOT NULL,
  owner_id      uuid         NOT NULL
    REFERENCES dt.dt_public.user (user_id)
      ON DELETE CASCADE,
  created_on    TIMESTAMP   NOT NULL,
  updated_on    TIMESTAMP   NOT NULL,
  PRIMARY KEY (tabletop_id)
);

I am trying to create a permissions that checks the incoming X-Hasura-test claim against the postgresql column owner_id which is of type uuid.

image

It appears that Hasura is casting the JWT claim as an integer instead of a string?

(((current_setting('hasura.user')::json->>'x-hasura-test'))::integer)

I am seeing this issue regardless of the key for the JWT claim i.e. X-Hasura-User-Id, X-Hasura-User-Uuid, X-Hasura-test, etc

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
0x777commented, Apr 17, 2019

The console may have picked them up (when you navigate to the table’s page in console) but the server needs to know that the schema has been modified on Postgres. Head to settings and hit ‘reload’.

0reactions
nccurrycommented, Apr 18, 2019

@0x777 That solved the issue thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SequelizeDatabaseError: operator does not exist uuid = integer
You should first check the models that you are including and their ID types. They must have same type. Beside that, let's say...
Read more >
Micronaut Framework/questions - Gitter
How can I secure my ServerWebSocket with jwt authentication? ... PSQLException: ERROR: operator does not exist: uuid = character varying Hint: No operator ......
Read more >
PostgreSQL connector | LoopBack Documentation
json file. If you create a PostgreSQL data source using the data source generator as described below, you don't have to do this,...
Read more >
The JWT Handbook
There are pros and cons to any approach, and client-side sessions are not an ... access to the authorization server, most of the...
Read more >
The Bitbucket Cloud REST API - Atlassian Developer
If your Atlassian Connect add-on uses JWT authentication, you can swap a JWT for an ... This scope alone does not give access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found