Error Loading 3 `no_attributes?: true` nested relationships

I'm running into an error that's very similar to one I encountered before. The structure is Grandpappy > has_many > Parent > has_many > Child > has_many Toy Grandparent also has_many :grandchild_toys via a no_attributes?: true relationship:
has_many :grandchild_toys, ErrorDemo.Demo.Toy do
no_attributes? true
public? true
filter expr(child.parent.grandpappy_id == parent(id))
end
has_many :grandchild_toys, ErrorDemo.Demo.Toy do
no_attributes? true
public? true
filter expr(child.parent.grandpappy_id == parent(id))
end
When I add three calculations (:foo, :bar and :baz) to Child, and all three need to load the grandchild toys like so...
@impl true
def load(_, _, _) do
[
parent: [grandpappy: [:grandchild_toys]]
]
end
@impl true
def load(_, _, _) do
[
parent: [grandpappy: [:grandchild_toys]]
]
end
... the following code results in an exception:
child |> Ash.load([:foo, :bar, :baz])

# raises:

%Ash.Error.Unknown.UnknownError{
error: "** (KeyError) key :grandpappy not found in: %ErrorDemo.Demo.Child
...
}
child |> Ash.load([:foo, :bar, :baz])

# raises:

%Ash.Error.Unknown.UnknownError{
error: "** (KeyError) key :grandpappy not found in: %ErrorDemo.Demo.Child
...
}
However, the following code works:
child = child |> Ash.load!([:foo, :bar]) |> Ash.load!(:baz)
child = child |> Ash.load!([:foo, :bar]) |> Ash.load!(:baz)
So it only seems to happen when loading all three in one go. https://github.com/enoonan/error_demo
GitHub
GitHub - enoonan/error_demo: Demos an error I'm getting loading com...
Demos an error I'm getting loading complex relationships / calculations - enoonan/error_demo
6 Replies
ZachDaniel
ZachDaniel4mo ago
latest versions of everything?
⿻ eileen
⿻ eileenOP4mo ago
Yup Using Elixir 1.18.2 and Erlang/OTP 27.
defp deps do
[
{:sourceror, "~> 1.8", only: [:dev, :test]},
{:ash_postgres, "~> 2.0"},
{:ash, "~> 3.0"},
{:igniter, "~> 0.6", only: [:dev, :test]}
]
end
defp deps do
[
{:sourceror, "~> 1.8", only: [:dev, :test]},
{:ash_postgres, "~> 2.0"},
{:ash, "~> 3.0"},
{:igniter, "~> 0.6", only: [:dev, :test]}
]
end
From mix.lock:
%{
"ash": {:hex, :ash, "3.5.17", ...},
"ash_postgres": {:hex, :ash_postgres, "2.6.6", ...
...
}
%{
"ash": {:hex, :ash, "3.5.17", ...},
"ash_postgres": {:hex, :ash_postgres, "2.6.6", ...
...
}
The readme on the github repo is a bit more fleshed out
ZachDaniel
ZachDaniel4mo ago
😠 my least favorite kind of bug lol
⿻ eileen
⿻ eileenOP4mo ago
Sorryyyyyyyyy
ZachDaniel
ZachDaniel4mo ago
please open an issue on Ash and include that reproduction
⿻ eileen
⿻ eileenOP4mo ago
Oky doke Done!

Did you find this page helpful?