ash-project / ash

A declarative, extensible framework for building Elixir applications.
https://www.ash-hq.org
MIT License
1.63k stars 216 forks source link

Manage relationship error paths sometimes empty #1456

Closed zeneodev1 closed 2 months ago

zeneodev1 commented 2 months ago

This issue is related to this closed issue.

It seems like to reproduce this bug i had to add data_layer: AshPostgres.DataLayer to the resources like the following

defmodule MyApp.MyDomain.MyResource do
  use Ash.Resource,
    data_layer: AshPostgres.DataLayer,
    domain: MyApp.MyDomain

  postgres do
    table "my_resource"
    repo MyApp.Repo
  end

  actions do
    defaults [:read, :update, :destroy]

    create :create do
      argument :related_resource, :map, allow_nil?: false

      change manage_relationship(:related_resource, :related_resource, type: :create)
    end
  end

  attributes do
    attribute :name, :string
  end

  relationships do
    belongs_to :related_resource, MyApp.MyDomain.RelatedResource
  end
end

defmodule MyApp.MyDomain.RelatedResource do
  use Ash.Resource,
    data_layer: AshPostgres.DataLayer,
    domain: MyApp.MyDomain

  postgres do
    table "related_resource"
    repo MyApp.Repo
  end

  actions do
    defaults [:read, :destroy, create: :*, update: :*]
  end

  attributes do
    attribute :required_attribute, :string, allow_nil?: false
  end

  relationships do
    belongs_to :my_resource, MyApp.MyDomain.MyResource
  end
end

Runtime

zachdaniel commented 2 months ago

Could you put together a reproduction project that has either a failing test or a function I can call from iex to reproduce the issue? To quickly scaffold a project:

mix archive.install hex igniter_new
mix igniter.new reproduction --install ash,ash_postgres
zeneodev1 commented 2 months ago

https://github.com/zeneodev1/ash-issue-reproduction