JSON-API Related() Seems Broken

Hi, 👋 there seems to be a regression in the JSON-API: It worked nicely (after you did a fix a couple of weeks ago), but after updating packages to the newest ones, I get an exception. Here’s the relation:
related(:events, :events_by_extid) do
route("/:extid/events")
end
related(:events, :events_by_extid) do
route("/:extid/events")
end
This is the exception I get:
[error] #PID<0.3383.0> running TickerWeb.Endpoint (connection #PID<0.3382.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /api/eventhub/alarms/R%201.5%20230310%201956/events
** (exit) an exception was raised:
** (UndefinedFunctionError) function :events.name/0 is undefined (module :events is not available)
:events.name()
(ash_json_api 0.32.0) lib/ash_json_api/controllers/helpers.ex:348: anonymous fn/1 in AshJsonApi.Controllers.Helpers.fetch_related/2
(ash_json_api 0.32.0) lib/ash_json_api/controllers/get_related.ex:20: AshJsonApi.Controllers.GetRelated.call/2
(ticker 0.1.0) deps/plug/lib/plug/router.ex:246: anonymous fn/4 in TickerWeb.Api.Router.dispatch/2
[...]
(cowboy 2.10.0) deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.10.0) deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.10.0) deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 4.3.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
[error] #PID<0.3383.0> running TickerWeb.Endpoint (connection #PID<0.3382.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /api/eventhub/alarms/R%201.5%20230310%201956/events
** (exit) an exception was raised:
** (UndefinedFunctionError) function :events.name/0 is undefined (module :events is not available)
:events.name()
(ash_json_api 0.32.0) lib/ash_json_api/controllers/helpers.ex:348: anonymous fn/1 in AshJsonApi.Controllers.Helpers.fetch_related/2
(ash_json_api 0.32.0) lib/ash_json_api/controllers/get_related.ex:20: AshJsonApi.Controllers.GetRelated.call/2
(ticker 0.1.0) deps/plug/lib/plug/router.ex:246: anonymous fn/4 in TickerWeb.Api.Router.dispatch/2
[...]
(cowboy 2.10.0) deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.10.0) deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.10.0) deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 4.3.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
3 Replies
Jan Ulbrich
Jan UlbrichOP•2y ago
Here are the packages I’m using (I tried it with the newest release of ash_json_api as well as the head):
defp deps do
[
{:absinthe_plug, "~> 1.5.8"},
{:ash, "~> 2.10.2"},
{:ash_authentication, "~> 3.11.6"},
{:ash_graphql, "~> 0.25.10"},
# {:ash_json_api, "~> 0.32.0"},
{:ash_json_api, git: "https://github.com/ash-project/ash_json_api.git", build: "main"},
{:ash_postgres, "~> 1.3.30"},
{:cors_plug, "~> 3.0.3"},
{:elixir_sense, ">= 1.0.0", only: [:dev, :test]},
{:ecto_sql, "~> 3.10.1"},
{:ecto_sqlite3, ">= 0.10.3"},
{:ex_phone_number, "== 0.3.0"},
{:guardian, "~> 2.3.1"},
{:haversine, "~> 0.1.0"},
{:jason, "~> 1.2"},
{:jose, "~> 1.11"},
{:open_api_spex, "~> 3.17.3"},
{:picosat_elixir, "~> 0.2.3"},
{:phoenix, "~> 1.6.16"},
{:phoenix_ecto, "~> 4.4.2"},
{:phoenix_html, "~> 3.3.1"},
{:plug_cowboy, "~> 2.6.1"},
{:postgrex, "~> 0.16.5"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:tesla, "~> 1.6.0"}
]
end
defp deps do
[
{:absinthe_plug, "~> 1.5.8"},
{:ash, "~> 2.10.2"},
{:ash_authentication, "~> 3.11.6"},
{:ash_graphql, "~> 0.25.10"},
# {:ash_json_api, "~> 0.32.0"},
{:ash_json_api, git: "https://github.com/ash-project/ash_json_api.git", build: "main"},
{:ash_postgres, "~> 1.3.30"},
{:cors_plug, "~> 3.0.3"},
{:elixir_sense, ">= 1.0.0", only: [:dev, :test]},
{:ecto_sql, "~> 3.10.1"},
{:ecto_sqlite3, ">= 0.10.3"},
{:ex_phone_number, "== 0.3.0"},
{:guardian, "~> 2.3.1"},
{:haversine, "~> 0.1.0"},
{:jason, "~> 1.2"},
{:jose, "~> 1.11"},
{:open_api_spex, "~> 3.17.3"},
{:picosat_elixir, "~> 0.2.3"},
{:phoenix, "~> 1.6.16"},
{:phoenix_ecto, "~> 4.4.2"},
{:phoenix_html, "~> 3.3.1"},
{:plug_cowboy, "~> 2.6.1"},
{:postgrex, "~> 0.16.5"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:tesla, "~> 1.6.0"}
]
end
ZachDaniel
ZachDaniel•2y ago
Yeah, this looks like a simple bug. Mind opening an issue in ash json api?
Jan Ulbrich
Jan UlbrichOP•2y ago
Sure, will do! Thanks!

Did you find this page helpful?