supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
1.04k stars 133 forks source link

Unsupported Media Type on .explain query #392

Closed jsbrain closed 1 year ago

jsbrain commented 1 year ago

Bug report

Describe the bug

.explain results in media error.

To Reproduce

const query = await supabase.from('test').select('*').explain();

results in

{
  error: {
    code: 'PGRST107',
    details: null,
    hint: null,
    message: 'None of these media types are available: application/vnd.pgrst.plan+text'
  },
  data: null,
  count: null,
  status: 415,
  statusText: 'Unsupported Media Type'
}

System information

jsbrain commented 1 year ago

Might be related to https://github.com/supabase/supabase-js/issues/691

steve-chavez commented 1 year ago

Hello, to use explain first you need to enable server side with:

alter role authenticator set pgrst.db_plan_enabled to true;
notify pgrst, 'reload config';

Let me know if that works.

jsbrain commented 1 year ago

Thanks @steve-chavez for the clarification.

Probably worth adding this to the docs.

Looks like so far .explain isn't documented at all!?

jsbrain commented 1 year ago

And unfortunately no, it did not work ... also restarted the deployment after I ran the commands but no change.

I'm on self-hosted btw. with this config.

steve-chavez commented 1 year ago

If you're on self-hosted, you can add PGRST_DB_PLAN_ENABLED: true here.

jsbrain commented 1 year ago

Still the same error ...

I tried to send a request directly to postgrest via Postman, setting the accept error as: shown here.

Output:

{
    "code": "PGRST107",
    "details": null,
    "hint": null,
    "message": "None of these media types are available: application/vnd.pgrst.plan+json"
}

Something is odd ... 🤔

steve-chavez commented 1 year ago

You're using an old version https://github.com/supabase/supabase/blob/f3031fa24fd4a65e7d48f079db45a0cd3ee0311c/docker/docker-compose.yml#L104

Change it to v10.1.1

jsbrain commented 1 year ago

Well, that solves the mystery. I was somehow under the impression that the docker-compose is up to date with the js clients.

Thanks so much for your help!