Unknown Error (OriginalDataNotAvailable) when trying to create a update

Hi guys.

I have this module, and I’m just trying to create an update:

defmodule Marketplace.Ap.Appointment do
  @moduledoc false

  alias Marketplace.Ap

  use Ash.Resource,
    data_layer: AshPostgres.DataLayer

  code_interface do
    define_for Marketplace.Ap

    define :create
    define :update

    define :get_by_lead
  end

  attributes do
    uuid_primary_key :id

    attribute :appt_type, :integer do
      description "In-Home = 1, Virtual = 2"
    end

    attribute :appointment_time, :utc_datetime_usec

    attribute :status, :string
    attribute :name_assigned_to, :string

    attribute :reschedule_uri, :string

    attribute :cancel_uri, :string
    attribute :cancel_reason, :string
    attribute :cancel_notes, :string

    attribute :cancel_by_type, :string

    attribute :score, :integer, allow_nil?: false

    timestamps()
  end

  relationships do
    belongs_to :canceled_by, Ap.User
    belongs_to :assigned_to, Ap.User

    belongs_to :assigned_by, Ap.User do
      primary_key? true
      allow_nil? false
      attribute_writable? true
    end

    belongs_to :lead, Ap.Lead do
      attribute_writable? true
    end
  end

  identities do
    identity :unique_id, [:lead_id]
  end

  postgres do
    table "appointment"

    schema "dbo"

    repo Marketplace.ApRepo
  end

  actions do
    alias Marketplace.Ap.Actions.Appointment.Actions.Create

    defaults [:read, :update]

    create :create do
      primary? true

      accept [:score]

      upsert? true
      upsert_fields [:score, :updated_at, :appt_type]
      upsert_identity :unique_id

      argument :lead_id, :uuid, allow_nil?: false
      argument :appt_type, :atom, allow_nil?: false

      change Create.Changes.FixApptType

      change set_attribute(:assigned_by_id, actor(:id))
      change set_attribute(:lead_id, arg(:lead_id))
    end

    read :get_by_lead do
      description "get appointment based on lead"

      argument :lead_id, :uuid, allow_nil?: false

      get? true

      filter expr(lead_id == ^arg(:lead_id))
    end
  end
end

However, when I try to access using iex:
[appt] = Marketplace.Ap.Appointment |> Marketplace.Ap.read!
Marketplace.Ap.Appointment.update(appt, %{cancel_notes: "hi"})

I end up with this error:

** (Ash.Error.Unknown) Unknown Error

* ** (KeyError) key :__meta__ not found in: %Ash.Changeset.OriginalDataNotAvailable{reason: :atomic_query_update}
  :erlang.map_get(:__meta__, %Ash.Changeset.OriginalDataNotAvailable{reason: :atomic_query_update})
  (elixir 1.16.0) lib/map.ex:318: Map.update!/3
  (ash_postgres 1.4.0) lib/data_layer.ex:1257: AshPostgres.DataLayer.update_query/4
  (ash 2.18.1) lib/ash/actions/update/bulk.ex:278: Ash.Actions.Update.Bulk.do_atomic_update/4
  (ash 2.18.1) lib/ash/actions/update/bulk.ex:120: Ash.Actions.Update.Bulk.run/5
  (ash 2.18.1) lib/ash/actions/update/update.ex:81: Ash.Actions.Update.run/4
  (marketplace 1.19.0) lib/marketplace/ap.ex:1: Marketplace.Ap.update/2
  (stdlib 5.0.2) erl_eval.erl:746: :erl_eval.do_apply/7
  (elixir 1.16.0) src/elixir.erl:378: :elixir.eval_forms/4
  (elixir 1.16.0) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
  (iex 1.16.0) lib/iex/evaluator.ex:331: IEx.Evaluator.eval_and_inspect/3
  (iex 1.16.0) lib/iex/evaluator.ex:305: IEx.Evaluator.eval_and_inspect_parsed/3
  (iex 1.16.0) lib/iex/evaluator.ex:294: IEx.Evaluator.parse_eval_inspect/4
  (iex 1.16.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
  (iex 1.16.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
  (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    :erlang.map_get(:__meta__, %Ash.Changeset.OriginalDataNotAvailable{reason: :atomic_query_update})
    (elixir 1.16.0) lib/map.ex:318: Map.update!/3
    (ash_postgres 1.4.0) lib/data_layer.ex:1257: AshPostgres.DataLayer.update_query/4
    (ash 2.18.1) lib/ash/actions/update/bulk.ex:278: Ash.Actions.Update.Bulk.do_atomic_update/4
    (ash 2.18.1) lib/ash/actions/update/bulk.ex:120: Ash.Actions.Update.Bulk.run/5
    (ash 2.18.1) lib/ash/actions/update/update.ex:81: Ash.Actions.Update.run/4
    (marketplace 1.19.0) lib/marketplace/ap.ex:1: Marketplace.Ap.update/2

Would anyone have any ideas on how to fix this?

hello! I’m assuming you’re using ash from main in that case. Can you also update ash_postgres to be from main as well?

Actually I’m using both ash and ash_postgres from main

  defp deps do
    [
      # Ash framework
      {:ash, github: "ash-project/ash", override: true},
      # {:ash, "~> 2.15", override: true},
      {:ash_authentication, "~> 3.12.1"},
      {:dataloader, "~> 2.0"},
      {:ash_graphql, "~> 0.26"},
      {:ash_query_builder, "~> 0.6.2"},
      {:elixir_sense, github: "elixir-lsp/elixir_sense", only: [:dev, :test]},
      {:ash_rbac, "== 0.3.2"},

      # ...

      # Database
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},
      {:postgrex, ">= 0.0.0"},
      # TODO: replace this line when ash_postgres is greater than 1.4.0
      {:ash_postgres, github: "ash-project/ash_postgres", override: true},
      {:ash_geo, "~> 0.1"}

      # ...
    ]
  end

I did some tests, and ended up realizing that all my updates for all resources are no longer working =/

They have different erros:

[error] GenServer #PID<0.1189.0> terminating
** (UndefinedFunctionError) function Marketplace.Markets.Property.Actions.OpenProperty.Validations.IsADraft.has_validate?/0 is undefined or private
    (marketplace 1.19.0) Marketplace.Markets.Property.Actions.OpenProperty.Validations.IsADraft.has_validate?()
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2005: Ash.Changeset.validate/5
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:1318: Ash.Changeset.do_for_action/4
    (marketplace 1.19.0) deps/ash/lib/ash/code_interface.ex:562: Marketplace.Markets.Property.open_property!/3
    (marketplace 1.19.0) lib/marketplace_web/live/admin/property/get_live.ex:65: MarketplaceWeb.Admin.Property.GetLive.handle_event/3
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:497: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.2.1) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:250: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
    (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-F6_RZBy6MuFZ2wlB", event: "event", payload: %{"event" => "open", "type" => "click", "value" => %{"value" => ""}}, ref: "12", join_ref: "11"}
State: %{socket: #Phoenix.LiveView.Socket<id: "phx-F6_RZBy6MuFZ2wlB", endpoint: MarketplaceWeb.Endpoint, view: MarketplaceWeb.Admin.Property.GetLive, parent_pid: nil, root_pid: #PID<0.1189.0>, router: MarketplaceWeb.Router, assigns: %{property: #Marketplace.Markets.Property<total_unique_offers: #Ash.NotLoaded<:calculation>, favorite?: false, offeror_current_offer: #Ash.NotLoaded<:calculation>, full_address: "124 Farmers Academy Road - Martin, GA - 30557", max_offer: #Ash.NotLoaded<:aggregate>, total_offers: #Ash.NotLoaded<:aggregate>, favorite_count: 0, total_valid_offer: #Ash.NotLoaded<:aggregate>, last_offer: #Ash.NotLoaded<:aggregate>, user_activities: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, disposition_agent: #Marketplace.Markets.User<full_name: #Ash.NotLoaded<:calculation>, favorite_properties_count: #Ash.NotLoaded<:aggregate>, offer: #Ash.NotLoaded<:relationship>, disposition_agent_to: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, property_activities: #Ash.NotLoaded<:relationship>, property_activities_join_assoc: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee", normalized_full_name: "admin general", first_name: "Admin", surname: "General", email: #Ash.CiString<"admin@email.com">, phone_number: "+1 (111) 111-1111", confirmed_at: ~U[2023-09-18 20:00:05.550684Z], roles: [:admin, :investor, :support], organization_roles: [:agent, :admin, :referral_code_manager, :disposition_agent], organization_id: "185e2073-baa8-48f7-ba7b-cc873104a528", aggregates: %{}, calculations: %{}, ...>, offers: #Ash.NotLoaded<:relationship>, property_user_activities: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "properties">, id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", street: "Farmers Academy Road", house_number: "124", city: "Martin", county: "Franklin", state: "GA", zip: "30557", country: "USA", type: :residential, sub_type: :multi_family, bedrooms: 4, bathrooms: Decimal.new("2.5"), square_foot: Decimal.new("2323"), lot_size: Decimal.new("78408"), year_built: 2022, ap_link: "https://www.google.com", cma_url: "https://ash-hq.org/", description: "<div>fewfwefwef</div>", repairs: "<div>Fwfefw<br><br>Jfeiwojfoiwjwofe<br><br>Blibs<br>Blobs<br>Blubs</div>", price: %Money{amount: 32000000, currency: :USD}, acquisition_price: %Money{amount: 23132100, currency: :USD}, due_diligence_date: ~D[2023-12-23], status: :draft, processing_status: :done, images: [#Marketplace.Markets.Property.Image<...>], external_id: "209934514", ...>, google_maps_api_key: "AIzaSyCbjRxmviO2mej2SdXlrEYOeZ3vNxkSm5c", __changed__: %{}, flash: %{}, current_user: #Marketplace.Accounts.User<full_name: "Admin General", organization_roles_as_string: #Ash.NotLoaded<:calculation>, total_active_deals: #Ash.NotLoaded<:aggregate>, disposition_agent_to: #Ash.NotLoaded<:relationship>, buy_box: #Ash.NotLoaded<:relationship>, referred_by: #Ash.NotLoaded<:relationship>, created_by: #Ash.NotLoaded<:relationship>, impersonate_permissions: #Ash.NotLoaded<:relationship>, preference: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, token: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee", email: #Ash.CiString<"admin@email.com">, phone_number: "+1 (111) 111-1111", first_name: "Admin", surname: "General", roles: [:admin, :investor, :support], organization_roles: [:agent, :admin, :referral_code_manager, :disposition_agent], confirmed_at: ~U[2023-09-18 20:00:05.550684Z], active?: true, allow_marketing_emails?: false, referral_code: "fc1992d8-527e-4b8b-b1d4-9b89868392ad", normalized_full_name: "admin general", inserted_at: ~U[2023-09-19 12:19:39.664146Z], updated_at: ~U[2024-01-18 14:54:03.923935Z], organization_id: "185e2073-baa8-48f7-ba7b-cc873104a528", created_by_id: nil, referred_by_id: nil, aggregates: %{}, calculations: %{}, ...>, property_id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", offers: %{}, pro_forma: nil, view_count: 0, loading?: false, live_action: :index, current_tab: :details, loading_offers?: false, agents: %{"4be7656f-ebca-4fc1-8de7-40d8c64900ee" => %{name: "Admin General", status: :viewing, joined_at: 1706813013, phx_ref: "F6_RZJvOF_UFNgHC"}}, slide_over: :none, current_image_index: 0, total_valid_offers: 0, grafana_dashboard_url: %URI{scheme: "https", authority: "grafana.rebuilt.com", userinfo: nil, host: "grafana.rebuilt.com", port: 443, path: "/d/ceea5201-4ca0-49c4-b653-c0cc2090f3a7/dev-property", query: "from=now-7d&orgId=1&to=now&var-property_id=ad466d6c-e631-4c32-9926-4a10ed7f73d6", fragment: nil}, loading_view_count?: false, loading_pro_forma?: false, view_slide_over?: false, current_tenant: nil}, transport_pid: #PID<0.1141.0>, ...>, components: {%{1 => {MarketplaceWeb.Admin.Property.GetLive.Components.PlaceOffer, "place_offer_ad466d6c-e631-4c32-9926-4a10ed7f73d6", %{id: "place_offer_ad466d6c-e631-4c32-9926-4a10ed7f73d6", form: #AshPhoenix.Form<resource: Marketplace.Markets.Offer, action: :place_offer_from_agent, type: :create, params: %{}, source: #Ash.Changeset<action_type: :create, action: :place_offer_from_agent, attributes: %{status: :submitted, property_id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", offeror_id: nil, seller_id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee"}, relationships: %{}, arguments: %{property_id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6"}, errors: [%Ash.Error.Changes.Required{field: :payment_type, type: :attribute, resource: Marketplace.Markets.Offer, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}, %Ash.Error.Changes.Required{field: :price, type: :attribute, resource: Marketplace.Markets.Offer, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}, %Ash.Error.Changes.InvalidAttribute{field: nil, message: "Property is still a draft", private_vars: nil, value: nil, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}, %Ash.Error.Changes.Required{field: :offeror_id, type: :argument, resource: Marketplace.Markets.Offer, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}], data: #Marketplace.Markets.Offer<seller: #Ash.NotLoaded<:relationship>, offeror: #Ash.NotLoaded<:relationship>, property: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:built, "offers">, (truncated)
[error] GenServer #PID<0.1282.0> terminating
** (Ash.Error.Unknown) Unknown Error

* ** (FunctionClauseError) no function clause matching in Ecto.Changeset.unique_constraint/3
  (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{updated_at: ~U[2024-02-01 18:45:38.000355Z], house_number: "1243", processing_status: :running}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
  (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash_postgres 1.4.0) lib/data_layer.ex:2135: AshPostgres.DataLayer.add_unique_indexes/3
  (ash_postgres 1.4.0) lib/data_layer.ex:1729: AshPostgres.DataLayer.ecto_changeset/5
  (ash_postgres 1.4.0) lib/data_layer.ex:2313: AshPostgres.DataLayer.update/2
  (ash 2.18.1) lib/ash/actions/update/update.ex:363: anonymous fn/5 in Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2822: Ash.Changeset.run_around_actions/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2405: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
  (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2403: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2542: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2384: Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:286: Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:173: Ash.Actions.Update.do_run/4
  (ash 2.18.1) lib/ash/actions/update/update.ex:132: Ash.Actions.Update.run/4
  (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2
  (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:1865: AshPhoenix.Form.with_changeset/2
  (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:1712: AshPhoenix.Form.submit/2
  (marketplace 1.19.0) lib/marketplace_web/live/admin/property/create_and_edit_common.ex:138: MarketplaceWeb.Admin.Property.CreateAndEditCommon.save_or_update/3
  (marketplace 1.19.0) lib/marketplace_web/live/admin/property/edit_live.ex:147: MarketplaceWeb.Admin.Property.EditLive.handle_info/2
  (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:349: Phoenix.LiveView.Channel.handle_info/2
  (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
  (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
  (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{updated_at: ~U[2024-02-01 18:45:38.000355Z], house_number: "1243", processing_status: :running}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_postgres 1.4.0) lib/data_layer.ex:2135: AshPostgres.DataLayer.add_unique_indexes/3
    (ash_postgres 1.4.0) lib/data_layer.ex:1729: AshPostgres.DataLayer.ecto_changeset/5
    (ash_postgres 1.4.0) lib/data_layer.ex:2313: AshPostgres.DataLayer.update/2
    (ash 2.18.1) lib/ash/actions/update/update.ex:363: anonymous fn/5 in Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2822: Ash.Changeset.run_around_actions/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2405: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2403: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2542: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2384: Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:286: Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:173: Ash.Actions.Update.do_run/4
    (ash 2.18.1) lib/ash/actions/update/update.ex:132: Ash.Actions.Update.run/4
    (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2
    (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:1865: AshPhoenix.Form.with_changeset/2
    (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:1712: AshPhoenix.Form.submit/2
    (marketplace 1.19.0) lib/marketplace_web/live/admin/property/create_and_edit_common.ex:138: MarketplaceWeb.Admin.Property.CreateAndEditCommon.save_or_update/3
    (marketplace 1.19.0) lib/marketplace_web/live/admin/property/edit_live.ex:147: MarketplaceWeb.Admin.Property.EditLive.handle_info/2
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:349: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
    (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: {:update, #AshPhoenix.Form<resource: Marketplace.Markets.Property, action: :update, type: :update, params: %{"acquisition_price" => "$ 231,321.00", "ap_link" => "https://www.google.com", "bathrooms" => "2.5", "bedrooms" => "4", "city" => "Martin", "cma_url" => "https://ash-hq.org/", "county" => "Franklin", "description" => "<div>fewfwefwef</div>", "disposition_agent_id" => "4be7656f-ebca-4fc1-8de7-40d8c64900ee", "due_diligence_date" => "2023-12-23", "external_id" => "209934514", "external_id_type" => "attom_id", "house_number" => "1243", "latitude" => "34", "longitude" => "-83.27512", "lot_size" => "78408", "price" => "$ 320,000.00", "repairs" => "<div>Fwfefw<br><br>Jfeiwojfoiwjwofe<br><br>Blibs<br>Blobs<br>Blubs</div>", "showing" => %{"_form_type" => "update", "_persistent_id" => "0", "floor_plan_url" => "", "inspection_url" => "", "original_show_date" => "", "timezone" => "cst", "tour_3d_url" => ""}, "square_foot" => "2323", "state" => "GA", "street" => "Farmers Academy Road", "sub_type" => "multi_family", "type" => "residential", "year_built" => "2022", "zip" => "30557"}, source: #Ash.Changeset<action_type: :update, action: :update, attributes: %{house_number: "1243"}, relationships: %{}, arguments: %{disposition_agent: nil, uploaded_images: [], removed_images: []}, errors: [], data: #Marketplace.Markets.Property<total_unique_offers: #Ash.NotLoaded<:calculation>, favorite?: false, offeror_current_offer: #Ash.NotLoaded<:calculation>, full_address: "124 Farmers Academy Road - Martin, GA - 30557", max_offer: #Ash.NotLoaded<:aggregate>, total_offers: #Ash.NotLoaded<:aggregate>, favorite_count: 0, total_valid_offer: #Ash.NotLoaded<:aggregate>, last_offer: #Ash.NotLoaded<:aggregate>, user_activities: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, disposition_agent: #Marketplace.Markets.User<full_name: #Ash.NotLoaded<:calculation>, favorite_properties_count: #Ash.NotLoaded<:aggregate>, offer: #Ash.NotLoaded<:relationship>, disposition_agent_to: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, property_activities: #Ash.NotLoaded<:relationship>, property_activities_join_assoc: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee", normalized_full_name: "admin general", first_name: "Admin", surname: "General", email: #Ash.CiString<"admin@email.com">, phone_number: "+1 (111) 111-1111", confirmed_at: ~U[2023-09-18 20:00:05.550684Z], roles: [:admin, :investor, :support], organization_roles: [:agent, :admin, :referral_code_manager, :disposition_agent], organization_id: "185e2073-baa8-48f7-ba7b-cc873104a528", aggregates: %{}, calculations: %{}, ...>, offers: #Ash.NotLoaded<:relationship>, property_user_activities: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "properties">, id: "82a0073e-2aad-4 (truncated)

Please try mix deps.update ash ash_postgres

After use mix deps.update ash ash_postgres my initial problem was solved. However I have other updates that give me those errors:

[error] GenServer #PID<0.1189.0> terminating
** (UndefinedFunctionError) function Marketplace.Markets.Property.Actions.OpenProperty.Validations.IsADraft.has_validate?/0 is undefined or private
    (marketplace 1.19.0) Marketplace.Markets.Property.Actions.OpenProperty.Validations.IsADraft.has_validate?()
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2005: Ash.Changeset.validate/5
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:1318: Ash.Changeset.do_for_action/4
    (marketplace 1.19.0) deps/ash/lib/ash/code_interface.ex:562: Marketplace.Markets.Property.open_property!/3
    (marketplace 1.19.0) lib/marketplace_web/live/admin/property/get_live.ex:65: MarketplaceWeb.Admin.Property.GetLive.handle_event/3
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:497: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.2.1) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:250: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
    (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-F6_RZBy6MuFZ2wlB", event: "event", payload: %{"event" => "open", "type" => "click", "value" => %{"value" => ""}}, ref: "12", join_ref: "11"}
State: %{socket: #Phoenix.LiveView.Socket<id: "phx-F6_RZBy6MuFZ2wlB", endpoint: MarketplaceWeb.Endpoint, view: MarketplaceWeb.Admin.Property.GetLive, parent_pid: nil, root_pid: #PID<0.1189.0>, router: MarketplaceWeb.Router, assigns: %{property: #Marketplace.Markets.Property<total_unique_offers: #Ash.NotLoaded<:calculation>, favorite?: false, offeror_current_offer: #Ash.NotLoaded<:calculation>, full_address: "124 Farmers Academy Road - Martin, GA - 30557", max_offer: #Ash.NotLoaded<:aggregate>, total_offers: #Ash.NotLoaded<:aggregate>, favorite_count: 0, total_valid_offer: #Ash.NotLoaded<:aggregate>, last_offer: #Ash.NotLoaded<:aggregate>, user_activities: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, disposition_agent: #Marketplace.Markets.User<full_name: #Ash.NotLoaded<:calculation>, favorite_properties_count: #Ash.NotLoaded<:aggregate>, offer: #Ash.NotLoaded<:relationship>, disposition_agent_to: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, property_activities: #Ash.NotLoaded<:relationship>, property_activities_join_assoc: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee", normalized_full_name: "admin general", first_name: "Admin", surname: "General", email: #Ash.CiString<"admin@email.com">, phone_number: "+1 (111) 111-1111", confirmed_at: ~U[2023-09-18 20:00:05.550684Z], roles: [:admin, :investor, :support], organization_roles: [:agent, :admin, :referral_code_manager, :disposition_agent], organization_id: "185e2073-baa8-48f7-ba7b-cc873104a528", aggregates: %{}, calculations: %{}, ...>, offers: #Ash.NotLoaded<:relationship>, property_user_activities: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "properties">, id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", street: "Farmers Academy Road", house_number: "124", city: "Martin", county: "Franklin", state: "GA", zip: "30557", country: "USA", type: :residential, sub_type: :multi_family, bedrooms: 4, bathrooms: Decimal.new("2.5"), square_foot: Decimal.new("2323"), lot_size: Decimal.new("78408"), year_built: 2022, ap_link: "https://www.google.com", cma_url: "https://ash-hq.org/", description: "<div>fewfwefwef</div>", repairs: "<div>Fwfefw<br><br>Jfeiwojfoiwjwofe<br><br>Blibs<br>Blobs<br>Blubs</div>", price: %Money{amount: 32000000, currency: :USD}, acquisition_price: %Money{amount: 23132100, currency: :USD}, due_diligence_date: ~D[2023-12-23], status: :draft, processing_status: :done, images: [#Marketplace.Markets.Property.Image<...>], external_id: "209934514", ...>, google_maps_api_key: "AIzaSyCbjRxmviO2mej2SdXlrEYOeZ3vNxkSm5c", __changed__: %{}, flash: %{}, current_user: #Marketplace.Accounts.User<full_name: "Admin General", organization_roles_as_string: #Ash.NotLoaded<:calculation>, total_active_deals: #Ash.NotLoaded<:aggregate>, disposition_agent_to: #Ash.NotLoaded<:relationship>, buy_box: #Ash.NotLoaded<:relationship>, referred_by: #Ash.NotLoaded<:relationship>, created_by: #Ash.NotLoaded<:relationship>, impersonate_permissions: #Ash.NotLoaded<:relationship>, preference: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, token: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee", email: #Ash.CiString<"admin@email.com">, phone_number: "+1 (111) 111-1111", first_name: "Admin", surname: "General", roles: [:admin, :investor, :support], organization_roles: [:agent, :admin, :referral_code_manager, :disposition_agent], confirmed_at: ~U[2023-09-18 20:00:05.550684Z], active?: true, allow_marketing_emails?: false, referral_code: "fc1992d8-527e-4b8b-b1d4-9b89868392ad", normalized_full_name: "admin general", inserted_at: ~U[2023-09-19 12:19:39.664146Z], updated_at: ~U[2024-01-18 14:54:03.923935Z], organization_id: "185e2073-baa8-48f7-ba7b-cc873104a528", created_by_id: nil, referred_by_id: nil, aggregates: %{}, calculations: %{}, ...>, property_id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", offers: %{}, pro_forma: nil, view_count: 0, loading?: false, live_action: :index, current_tab: :details, loading_offers?: false, agents: %{"4be7656f-ebca-4fc1-8de7-40d8c64900ee" => %{name: "Admin General", status: :viewing, joined_at: 1706813013, phx_ref: "F6_RZJvOF_UFNgHC"}}, slide_over: :none, current_image_index: 0, total_valid_offers: 0, grafana_dashboard_url: %URI{scheme: "https", authority: "grafana.rebuilt.com", userinfo: nil, host: "grafana.rebuilt.com", port: 443, path: "/d/ceea5201-4ca0-49c4-b653-c0cc2090f3a7/dev-property", query: "from=now-7d&orgId=1&to=now&var-property_id=ad466d6c-e631-4c32-9926-4a10ed7f73d6", fragment: nil}, loading_view_count?: false, loading_pro_forma?: false, view_slide_over?: false, current_tenant: nil}, transport_pid: #PID<0.1141.0>, ...>, components: {%{1 => {MarketplaceWeb.Admin.Property.GetLive.Components.PlaceOffer, "place_offer_ad466d6c-e631-4c32-9926-4a10ed7f73d6", %{id: "place_offer_ad466d6c-e631-4c32-9926-4a10ed7f73d6", form: #AshPhoenix.Form<resource: Marketplace.Markets.Offer, action: :place_offer_from_agent, type: :create, params: %{}, source: #Ash.Changeset<action_type: :create, action: :place_offer_from_agent, attributes: %{status: :submitted, property_id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", offeror_id: nil, seller_id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee"}, relationships: %{}, arguments: %{property_id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6"}, errors: [%Ash.Error.Changes.Required{field: :payment_type, type: :attribute, resource: Marketplace.Markets.Offer, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}, %Ash.Error.Changes.Required{field: :price, type: :attribute, resource: Marketplace.Markets.Offer, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}, %Ash.Error.Changes.InvalidAttribute{field: nil, message: "Property is still a draft", private_vars: nil, value: nil, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}, %Ash.Error.Changes.Required{field: :offeror_id, type: :argument, resource: Marketplace.Markets.Offer, changeset: nil, query: nil, error_context: [], vars: [], path: [], stacktrace: #Stacktrace<>, class: :invalid}], data: #Marketplace.Markets.Offer<seller: #Ash.NotLoaded<:relationship>, offeror: #Ash.NotLoaded<:relationship>, property: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:built, "offers">, (truncated)
[error] GenServer #PID<0.1282.0> terminating
** (Ash.Error.Unknown) Unknown Error

* ** (FunctionClauseError) no function clause matching in Ecto.Changeset.unique_constraint/3
  (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{updated_at: ~U[2024-02-01 18:45:38.000355Z], house_number: "1243", processing_status: :running}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
  (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash_postgres 1.4.0) lib/data_layer.ex:2135: AshPostgres.DataLayer.add_unique_indexes/3
  (ash_postgres 1.4.0) lib/data_layer.ex:1729: AshPostgres.DataLayer.ecto_changeset/5
  (ash_postgres 1.4.0) lib/data_layer.ex:2313: AshPostgres.DataLayer.update/2
  (ash 2.18.1) lib/ash/actions/update/update.ex:363: anonymous fn/5 in Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2822: Ash.Changeset.run_around_actions/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2405: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
  (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2403: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2542: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2384: Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:286: Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:173: Ash.Actions.Update.do_run/4
  (ash 2.18.1) lib/ash/actions/update/update.ex:132: Ash.Actions.Update.run/4
  (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2
  (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:1865: AshPhoenix.Form.with_changeset/2
  (ash_phoenix 1.2.26) lib/ash_phoenix/form/form.ex:1712: AshPhoenix.Form.submit/2
  (marketplace 1.19.0) lib/marketplace_web/live/admin/property/create_and_edit_common.ex:138: MarketplaceWeb.Admin.Property.CreateAndEditCommon.save_or_update/3
  (marketplace 1.19.0) lib/marketplace_web/live/admin/property/edit_live.ex:147: MarketplaceWeb.Admin.Property.EditLive.handle_info/2
  (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:349: Phoenix.LiveView.Channel.handle_info/2
  (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3

I tried change to {:ash, "~> 2.18", override: true} and {:ash_postgres, "~> 1.4"}.

In this version update works fine. on master they dont.

If you prefer I can create a new topic

First error I got it:

It seems that on master we must use use Ash.Resource.Validation (before it worked without it, but it makes sense to be mandatory).

But still have the second one


FunctionClauseError) no function clause matching in Ecto.Changeset.unique_constraint/3
...

Correct, use Ash.Resource.Validation will be necessary.

I’m not familiar w/ that specific error, can you paste the full stacktrace/error message?

This one?

Once again, on {:ash, "~> 2.18", override: true} and {:ash_postgres, "~> 1.4"}, was working, now I got error :disappointed_relieved:

[error] GenServer #PID<0.11259.0> terminating
** (Ash.Error.Unknown) Unknown Error

* ** (FunctionClauseError) no function clause matching in Ecto.Changeset.unique_constraint/3
  (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{status: :open, updated_at: ~U[2024-02-01 19:22:15.687640Z], opened_at: ~U[2024-02-01 19:22:15Z]}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
  (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash_postgres 1.4.0) lib/data_layer.ex:2142: AshPostgres.DataLayer.add_unique_indexes/3
  (ash_postgres 1.4.0) lib/data_layer.ex:1736: AshPostgres.DataLayer.ecto_changeset/5
  (ash_postgres 1.4.0) lib/data_layer.ex:2320: AshPostgres.DataLayer.update/2
  (ash 2.18.1) lib/ash/actions/update/update.ex:363: anonymous fn/5 in Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2822: Ash.Changeset.run_around_actions/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2405: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
  (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2403: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2542: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2384: Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:286: Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:173: Ash.Actions.Update.do_run/4
  (ash 2.18.1) lib/ash/actions/update/update.ex:132: Ash.Actions.Update.run/4
  (ash 2.18.1) lib/ash/api/api.ex:2723: Ash.Api.update!/3
  (marketplace 1.19.0) lib/marketplace_web/live/admin/property/get_live.ex:65: MarketplaceWeb.Admin.Property.GetLive.handle_event/3
  (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:497: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
  (telemetry 1.2.1) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
  (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:250: Phoenix.LiveView.Channel.handle_info/2
  (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
  (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
  (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{status: :open, updated_at: ~U[2024-02-01 19:22:15.687640Z], opened_at: ~U[2024-02-01 19:22:15Z]}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_postgres 1.4.0) lib/data_layer.ex:2142: AshPostgres.DataLayer.add_unique_indexes/3
    (ash_postgres 1.4.0) lib/data_layer.ex:1736: AshPostgres.DataLayer.ecto_changeset/5
    (ash_postgres 1.4.0) lib/data_layer.ex:2320: AshPostgres.DataLayer.update/2
    (ash 2.18.1) lib/ash/actions/update/update.ex:363: anonymous fn/5 in Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2822: Ash.Changeset.run_around_actions/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2405: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2403: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2542: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2384: Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:286: Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:173: Ash.Actions.Update.do_run/4
    (ash 2.18.1) lib/ash/actions/update/update.ex:132: Ash.Actions.Update.run/4
    (ash 2.18.1) lib/ash/api/api.ex:2723: Ash.Api.update!/3
    (marketplace 1.19.0) lib/marketplace_web/live/admin/property/get_live.ex:65: MarketplaceWeb.Admin.Property.GetLive.handle_event/3
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:497: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.2.1) /home/jeferson/workspace/rebuilt/platform/marketplace/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (phoenix_live_view 0.20.3) lib/phoenix_live_view/channel.ex:250: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 5.0.2) gen_server.erl:1077: :gen_server.try_handle_info/3
    (stdlib 5.0.2) gen_server.erl:1165: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-F6_TgFjkQXV7tmgG", event: "event", payload: %{"event" => "open", "type" => "click", "value" => %{"value" => ""}}, ref: "8", join_ref: "4"}
State: %{socket: #Phoenix.LiveView.Socket<id: "phx-F6_TgFjkQXV7tmgG", endpoint: MarketplaceWeb.Endpoint, view: MarketplaceWeb.Admin.Property.GetLive, parent_pid: nil, root_pid: #PID<0.11259.0>, router: MarketplaceWeb.Router, assigns: %{property: #Marketplace.Markets.Property<total_unique_offers: #Ash.NotLoaded<:calculation>, favorite?: false, offeror_current_offer: #Ash.NotLoaded<:calculation>, full_address: "124 Farmers Academy Road - Martin, GA - 30557", max_offer: #Ash.NotLoaded<:aggregate>, total_offers: #Ash.NotLoaded<:aggregate>, favorite_count: 0, total_valid_offer: #Ash.NotLoaded<:aggregate>, last_offer: #Ash.NotLoaded<:aggregate>, user_activities: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, disposition_agent: #Marketplace.Markets.User<full_name: #Ash.NotLoaded<:calculation>, favorite_properties_count: #Ash.NotLoaded<:aggregate>, offer: #Ash.NotLoaded<:relationship>, disposition_agent_to: #Ash.NotLoaded<:relationship>, organization: #Ash.NotLoaded<:relationship>, property_activities: #Ash.NotLoaded<:relationship>, property_activities_join_assoc: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "4be7656f-ebca-4fc1-8de7-40d8c64900ee", normalized_full_name: "admin general", first_name: "Admin", surname: "General", email: #Ash.CiString<"admin@email.com">, phone_number: "+1 (111) 111-1111", confirmed_at: ~U[2023-09-18 20:00:05.550684Z], roles: [:admin, :investor, :support], organization_roles: [:agent, :admin, :referral_code_manager, :disposition_agent], organization_id: "185e2073-baa8-48f7-ba7b-cc873104a528", aggregates: %{}, calculations: %{}, ...>, offers: #Ash.NotLoaded<:relationship>, property_user_activities: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "properties">, id: "ad466d6c-e631-4c32-9926-4a10ed7f73d6", street: "Farmers Academy Road", house_number: "124", city: "Martin", county: "Franklin", state: "GA", zip: "30557", country: "USA", type: :residential, sub_type: :multi_family, bedrooms: 4, bathrooms: Decimal.new("2.5"), square_foot: Decimal.new("2323"), lot_size: Decimal.new("78408"), year_built: 2022, ap_link: "https://www.google.com", cma_url: "https://ash-hq.org/", description: "<div>fewfwefwef</div>", repairs: "<div>Fwfefw<br><br>Jfeiwojfoiwjwofe<br><br>Blibs<br>Blobs<br>Blubs</div>", price: %Money{amount: 32000000, currency: :USD}, acquisition_price: %Money{amount: 23132100, currency: :USD}, due_diligence_date: ~D[2023-12-23], status: :draft, processing_status: :done, images: [#Marketplace.Markets.Property.Image<...>], external_id: "209934514", ...>, google_maps_api_key: "AIzaSyCbjRxmviO2mej2SdXlrEYOeZ3vNxkSm5c", loading?: false, current_user: #Marketplace.Accounts.User<full_name: "Admin General", organization_roles_as_string: #Ash.NotLoaded<:calculation>, total_active_deals: #Ash.NotLoaded<:aggregate>, disposition_agent_to: #Ash.NotLoaded (truncated)

Okay, try ash_postgres main again please. mix deps.update ash_postgres. Lots of people work against main branches, but just keep in mind that we’re gearing up for the 3.0 release, and are making some relatively significant changes in main. Its starting to stabilize, just want to make sure you’re aware.

Still having the same error :upside_down_face:

Cool. I just added the version so you have the reference

:man_facepalming: my git push failed and I didn’t notice. Try again

Real-time support :man_surfing: :man_surfing: :man_surfing:

✗ mix compile                 
==> ash_postgres
Compiling 45 files (.ex)
      error: undefined variable "keys"
      │
 2145 │         Ecto.Changeset.unique_constraint(changeset, keys, opts)
      │                                                     ^^^^
      │
      └─ lib/data_layer.ex:2145:53: AshPostgres.DataLayer.add_unique_indexes/3


== Compilation error in file lib/data_layer.ex ==
** (CompileError) lib/data_layer.ex: cannot compile module AshPostgres.DataLayer (errors have been logged)

could not compile dependency :ash_postgres, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile ash_postgres --force", update it with "mix deps.update ash_postgres" or clean it with "mix deps.clean ash_postgres"

okay, this time for real :crying_cat_face:

Yay! At least now the error has changed (printing debug just because):

[debug] QUERY OK source="transactions" db=2.1ms
INSERT INTO "carbonite_default"."transactions" ("meta","inserted_at") VALUES ($1,$2) ON CONFLICT ("id") DO UPDATE SET "id" = EXCLUDED."id" RETURNING "inserted_at","meta","xact_id","id" [%{type: "update_view_count", actor: nil}, ~U[2024-02-01 20:22:04.037630Z]]
[debug] QUERY OK db=0.2ms
rollback []
** (Ash.Error.Unknown) Unknown Error

* ** (KeyError) key :resource not found in: #Ecto.Changeset<
  action: nil,
  changes: %{updated_at: ~U[2024-02-01 20:22:04.040457Z], view_count: 1},
  errors: [],
  data: #Marketplace.Markets.Property<>,
  valid?: true
>
  (ash_postgres 1.4.0) lib/data_layer.ex:2120: AshPostgres.DataLayer.add_unique_indexes/3
  (ash_postgres 1.4.0) lib/data_layer.ex:1736: AshPostgres.DataLayer.ecto_changeset/5
  (ash_postgres 1.4.0) lib/data_layer.ex:2330: AshPostgres.DataLayer.update/2
  (ash 2.18.1) lib/ash/actions/update/update.ex:366: anonymous fn/5 in Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2823: Ash.Changeset.run_around_actions/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2406: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
  (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2404: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2543: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2385: Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:289: Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:176: Ash.Actions.Update.do_run/4
  (ash 2.18.1) lib/ash/actions/update/update.ex:135: Ash.Actions.Update.run/4
  (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2
  (stdlib 5.0.2) erl_eval.erl:746: :erl_eval.do_apply/7
  (elixir 1.16.0) src/elixir.erl:378: :elixir.eval_forms/4
  (elixir 1.16.0) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
  (iex 1.16.0) lib/iex/evaluator.ex:331: IEx.Evaluator.eval_and_inspect/3
  (iex 1.16.0) lib/iex/evaluator.ex:305: IEx.Evaluator.eval_and_inspect_parsed/3
  (iex 1.16.0) lib/iex/evaluator.ex:294: IEx.Evaluator.parse_eval_inspect/4
  (iex 1.16.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
  (iex 1.16.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
  (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (ash_postgres 1.4.0) lib/data_layer.ex:2120: AshPostgres.DataLayer.add_unique_indexes/3
    (ash_postgres 1.4.0) lib/data_layer.ex:1736: AshPostgres.DataLayer.ecto_changeset/5
    (ash_postgres 1.4.0) lib/data_layer.ex:2330: AshPostgres.DataLayer.update/2
    (ash 2.18.1) lib/ash/actions/update/update.ex:366: anonymous fn/5 in Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2823: Ash.Changeset.run_around_actions/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2406: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2404: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2543: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2385: Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:289: Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:176: Ash.Actions.Update.do_run/4
    (ash 2.18.1) lib/ash/actions/update/update.ex:135: Ash.Actions.Update.run/4
    (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2

1 Like

Not normally this all over the place, but I’m presently working on about 6 different things. Sorry bout that :laughing:

No problem sr. If I’m bothering you, I can go back to the stable version. I’m only using main because I had the problem with 2 databases and migration was crazy.

But I think now we get back to the prevous error:

** (Ash.Error.Unknown) Unknown Error

* ** (FunctionClauseError) no function clause matching in Ecto.Changeset.unique_constraint/3
  (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{updated_at: ~U[2024-02-01 20:31:08.375531Z], view_count: 1}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
  (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash_postgres 1.4.0) lib/data_layer.ex:2152: AshPostgres.DataLayer.add_unique_indexes/3
  (ash_postgres 1.4.0) lib/data_layer.ex:1736: AshPostgres.DataLayer.ecto_changeset/5
  (ash_postgres 1.4.0) lib/data_layer.ex:2330: AshPostgres.DataLayer.update/2
  (ash 2.18.1) lib/ash/actions/update/update.ex:366: anonymous fn/5 in Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2823: Ash.Changeset.run_around_actions/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2406: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
  (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2404: anonymous fn/3 in Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2543: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
  (ash 2.18.1) lib/ash/changeset/changeset.ex:2385: Ash.Changeset.with_hooks/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:289: Ash.Actions.Update.commit/3
  (ash 2.18.1) lib/ash/actions/update/update.ex:176: Ash.Actions.Update.do_run/4
  (ash 2.18.1) lib/ash/actions/update/update.ex:135: Ash.Actions.Update.run/4
  (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2
  (stdlib 5.0.2) erl_eval.erl:746: :erl_eval.do_apply/7
  (elixir 1.16.0) src/elixir.erl:378: :elixir.eval_forms/4
  (elixir 1.16.0) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
  (iex 1.16.0) lib/iex/evaluator.ex:331: IEx.Evaluator.eval_and_inspect/3
  (iex 1.16.0) lib/iex/evaluator.ex:305: IEx.Evaluator.eval_and_inspect_parsed/3
  (iex 1.16.0) lib/iex/evaluator.ex:294: IEx.Evaluator.parse_eval_inspect/4
  (iex 1.16.0) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
  (iex 1.16.0) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
  (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (ecto 3.11.1) Ecto.Changeset.unique_constraint(#Ecto.Changeset<action: nil, changes: %{updated_at: ~U[2024-02-01 20:31:08.375531Z], view_count: 1}, errors: [], data: #Marketplace.Markets.Property<>, valid?: true>, [], [name: "properties_normalized_full_address_gin_trgm_ops"])
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ash_postgres 1.4.0) lib/data_layer.ex:2152: AshPostgres.DataLayer.add_unique_indexes/3
    (ash_postgres 1.4.0) lib/data_layer.ex:1736: AshPostgres.DataLayer.ecto_changeset/5
    (ash_postgres 1.4.0) lib/data_layer.ex:2330: AshPostgres.DataLayer.update/2
    (ash 2.18.1) lib/ash/actions/update/update.ex:366: anonymous fn/5 in Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2823: Ash.Changeset.run_around_actions/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2406: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1358: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
    (db_connection 2.6.0) lib/db_connection.ex:1710: DBConnection.run_transaction/4
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2404: anonymous fn/3 in Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2543: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
    (ash 2.18.1) lib/ash/changeset/changeset.ex:2385: Ash.Changeset.with_hooks/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:289: Ash.Actions.Update.commit/3
    (ash 2.18.1) lib/ash/actions/update/update.ex:176: Ash.Actions.Update.do_run/4
    (ash 2.18.1) lib/ash/actions/update/update.ex:135: Ash.Actions.Update.run/4
    (marketplace 1.19.0) lib/marketplace/markets.ex:1: Marketplace.Markets.update/2

Does your resource have a primary key?

Where does this: properties_normalized_full_address_gin_trgm_ops come from? I’m assuming thats something you’ve added manually?