Similar to #166 but occurs for related routes, not includes.
When attempting to access the related route for a relationship that is not marked public? true, a confusing error message is returned.
To Reproduce
The resource:
Tunez.Music.Artist:
json_api do
type "artist"
routes do
base "/artists"
related :albums, :read
end
end
relationships do
has_many :albums, Tunez.Music.Album do
# public? true
end
end
[error] ** (KeyError) key :destination not found in: nil
If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
(ash_json_api 1.2.0) lib/ash_json_api/controllers/get_related.ex:16: AshJsonApi.Controllers.GetRelated.call/2
(tunez 0.1.0) deps/plug/lib/plug/router.ex:246: anonymous fn/4 in TunezWeb.JsonAPIRouter.dispatch/2
(telemetry 1.2.1) /Users/rebecca/Projects/work/book/tunez/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
(tunez 0.1.0) deps/plug/lib/plug/router.ex:242: TunezWeb.JsonAPIRouter.dispatch/2
(tunez 0.1.0) lib/tunez_web/json_api_router.ex:1: TunezWeb.JsonAPIRouter.plug_builder_call/2
(phoenix 1.7.12) lib/phoenix/router/route.ex:42: Phoenix.Router.Route.call/2
...
If uncommenting the public? true line on the relationship, the request works as expected.
Expected behavior
A properly formatted JSON response to the user that they've requested something invalid.
I wonder if we could also make it a compilation error for the developer - you can't request something that isn't public?
Runtime
Elixir version 1.17.0-otp-27
Erlang version 27.0
OS macOS Sonoma
Ash version 3.0.12
AshJsonApi version main branch at commit 0bbdd179fa9fe06d78f5881fd02b03ebfeeee747
Describe the bug
Similar to #166 but occurs for
related
routes, not includes.When attempting to access the
related
route for a relationship that is not markedpublic? true
, a confusing error message is returned.To Reproduce
The resource:
Tunez.Music.Artist
:The request:
http://localhost:4000/api/artists/4fad50ae-9f07-49c1-a04a-560477a5d47d/albums
The error:
If uncommenting the
public? true
line on the relationship, the request works as expected.Expected behavior
A properly formatted JSON response to the user that they've requested something invalid.
I wonder if we could also make it a compilation error for the developer - you can't request something that isn't public?
Runtime