PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
22.65k stars 1k forks source link

Return 404 on none existing endpoint with resource embedding #3602

Open DutchGerman opened 1 week ago

DutchGerman commented 1 week ago

Environment

Description of issue

When making a request to a none existing endpoint that includes resource embedding, it returns an error 400.

GET /none_existing_endpoint?select=title,directors(id,last_name) HTTP/1.1

Response: 400 Bad Request
{
    "code": "PGRST200",
    "details": "Searched for a foreign key relationship between 'none_existing_endpoint' and 'directors' in the schema 'exposed', but no matches were found.",
    "hint": null,
    "message": "Could not find a relationship between 'none_existing_endpoint' and 'directors' in the schema cache"
}

I would expect an 404 that tells me that the endpoint itself does not exist like so:


GET /none_existing_endpoint?select=title,directors(id,last_name) HTTP/1.1

Response: 404 Bad Request
{
    "code": "42P01",
    "details": null,
    "hint": null,
    "message": "relation \"exposed.none_existing_endpoint\" does not exist"
}