This seems maybe somewhat related to this issue, as it looks to be the exact same thing?
But for the life of me I cannot tell what is causing this.
I have a resource where i’m trying to get the complete
update to work
defmodule App.Pipelines.Run do
use Ash.Resource,
data_layer: AshPostgres.DataLayer,
authorizers: [Ash.Policy.Authorizer],
domain: App.Pipelines
postgres do
table "runs"
repo App.Repo
end
attributes do
uuid_primary_key :run_id
attribute :oban_job_id, :integer, allow_nil?: true, public?: true
attribute :run_status, :string, allow_nil?: true, public?: true
attribute :result, :map, allow_nil?: true, public?: true
create_timestamp :created_at
update_timestamp :updated_at
end
code_interface do
define :create, action: :create
define :read_all, action: :read
define :update, action: :update
define :delete, action: :destroy
define :complete, action: :complete
define :get_run, args: [:run_id], action: :by_id
define :get_runs_by_date_range, args: [:start_date, :end_date], action: :by_date_range
end
actions do
defaults [:destroy, :read, update: :*]
create :create do
accept [:*]
# Make this action the primary action, so if you call some generic :create action, it defaults to this
primary? true
argument :pipeline_id, :uuid, allow_nil?: false
change set_attribute(:pipeline_id, arg(:pipeline_id))
end
read :by_id do
# This action has one argument :run_id of type :uuid
argument :run_id, :uuid, allow_nil?: false
# Tells us we expect this action to return a sinle result
get? true
# Filters the `:id` given in the argument
# against the `id` of each element in the resource
filter expr(run_id == ^arg(:run_id))
prepare build(load: [:pipeline])
end
update :complete do
accept [:result]
change set_attribute(:run_status, "SUCCESS")
notifiers [App.Notifiers.RunNotifier]
end
read :by_date_range do
argument :start_date, :date, allow_nil?: false
argument :end_date, :date, allow_nil?: false
filter expr(created_at >= ^arg(:start_date) and created_at <= ^arg(:end_date))
end
end
relationships do
belongs_to :pipeline, Smol.Pipelines.Pipeline
end
policies do
policy action_type(:read) do
authorize_if relates_to_actor_via([:pipeline, :user])
end
end
end
But whenever I call the action like this
{:ok, run} =
Run.complete(
run,
%{
result: result
},
authorize?: false
)
where result looks like this
%{
summary: %{
chat_history: [
%{"content" => "Default system prompt", "role" => "system"},
%{
"content" =>
"Here's a collection of tweets from the Twitter list 'Web 3 Mid':\nTweet by KhanAbbas201 (2024-08-26 19:40:13.000000Z):\n@Rahatcodes told me I look good wearing the Eth shirt. https://t.co/xBugAt2tDi\nTweet by Rahatcodes (2024-08-26 19:42:55.000000Z):\n@KhanAbbas201 I dont recall saying this\nTweet by KhanAbbas201 (2024-08-26 19:44:08.000000Z):\n@Rahatcodes Damn what happened to your memory bruv?\nTweet by angelinarusse (2024-08-26 19:56:05.000000Z):\n@dabit3 Real degens call it Twitter\nTweet by angelinarusse (2024-08-26 20:13:58.000000Z):\n@hamseth They tried the same in Afghanistan and it didn’t go well for them.\nTweet by KhanAbbas201 (2024-08-26 20:39:53.000000Z):\nTweet by Osh_mahajan (2024-08-26 21:34:08.000000Z):\n@FedericoNoemie 🐾🐾🦘\nTweet by developer_dao (2024-08-26 21:39:59.000000Z):\n@ZwigoZwitscher @ArweaveEco @k4yls Wildly high praise, ty ty. @k4yls is 🔥 with a 🐶\nTweet by developer_dao (2024-08-26 21:41:17.000000Z):\nRT @ZwigoZwitscher : I've been into @ArweaveEco for years – as an interested outsider – and still learned new things in that course 👇. Thanks…\nTweet by angelin...eet by developer_dao (2024-08-26 22:18:09.000000Z):\nRT @jeremykauffman: BREAKING: France has arrested Gonzalve Bich, the CEO of Bic\nTweet by PatrickAlphaC (2024-08-26 22:26:16.000000Z):\n@oxfav @ar_io_network\n",
"role" => "user"
},
%{"content" => "test", "role" => "user"},
%{
"content" => "It looks like you're testing the feature. How can I assist you further?",
"role" => "assistant"
}
]
}
}
I get these errors logged out.
[debug] QUERY ERROR source="runs" db=6.5ms queue=0.4ms idle=1374.0ms
t(
"(ARRAY[?,?,?,?])",
^%{"content" => "Default system prompt", "role" => "system"},
^%{"content" => "Here's a collection of tweets from the Twitter list 'Web 3 Mid':\n\nTweet by Aayush_gupta_ji (2024-08-26 05:08:32.000000Z):\nMy simple PR is merged in @CyfrinUpdraft / @ProgrammerSmart DeFi course.\n 16, url: https://twitter.com/Aayush_gupta_ji/status/1827936142785699862\n\nTweet by aahiknsv (2024-08-26 06:58:22.000000Z):\nHellu cutiess!! \n\nWho's interested in joining a live workflow-building session with @lemme_build tomorrow on Zoom?\n\nDrop a comment!\n 36, url: https://twitter.com/aahiknsv/status/1827963782745755873\n\nTweet by saminacodes (2024-08-26 07:13:06.000000Z):\nRT @SherzyOne: “If you had invested in Apple in 2007…”\n\nMe in 07: https://t.co/DsGOkSfHkI\n 0, url: https://twitter.com/saminacodes/status/1827967490997080094\n\nTweet by Aayush_gupta_ji (2024-08-26 07:13:23.000000Z):\n@uttam_singhk Sorry for your loss. \n\nMay God grant peace to his soul.\n 1, url: https://twitter.com/Aayush_gupta_ji/status/1827967561729749368\n\nTweet by BhosalePratim (2024-08-26 07:19:13.000000Z):\nA big chunk of population(residing across the globe) needs to fix their scarcity mindset and stop getting jealous over the success of fellow Indians( or Indian origin people)\n\nThis mentality is hurting the whole community. \n\nIf things aren't working for you, take risks and get out of the rut.\n\nI don't think @deedydas needs to answer to this dumb hate.\n\nCongratulations on your green card @deedydas! And keep writing!\n 16, url: https://twitter.com/BhosalePratim/status/1827969028842996159\n\nTweet by ThisisVanshika (2024-08-26 07:28:50.000000Z):\n@SuhailKakar Its definitely difficult ! \nThe amount of paperwork required for each single visa and every single year\n 1, url: https://twitter.com/ThisisVanshika/status/1827971451607032157\n\nTweet by ThisisVanshika (2024-08-26 07:29:38.000000Z):\n@emceecoy_ gm\n 1, url: https://twitter.com/ThisisVanshika/status/1827971650068856873\n\nTweet by dhaiwat10 (2024-08-26 07:30:20.000000Z):\n@grow_love @MichelleBakels Happy birthday Michelle!\n 1, url: https://twitter.com/dhaiwat10/status/1827971827060056420\n\nTweet by saminacodes (2024-08-26 07:32:46.000000Z):\nRT @growing_daniel: Getting busy irl will make you realize how deeply and truly unreal twitter is\n 0, url: https://twitter.com/saminacodes/status/1827972438354710689\n\nTweet by SuhailKakar (2024-08-26 07:51:33.000000Z):\n@imranfaststart @weneverleftt i'm down! my dms are open for all type of collaboration :)\n 1, url: https://twitter.com/SuhailKakar/status/1827977168246173915\n\nTweet by SuhailKakar (2024-08-26 07:51:59.000000Z):\n@httpJunkie @Nikhil_Mahana at least, india's passport is much better than mine :)\n 0, url: https://twitter.com/SuhailKakar/status/1827977275196780577\n\nTweet by edatweets_ (2024-08-26 09:42:44.000000Z):\npretty cool that there are >180K basenames registered is less than a week. More than half paid 💰 https://t.co/fRJFjjsAai\n 14, url: https://twitter.com/edatweets_/status/1828005148083273803\n\nTweet by aahiknsv (2024-08-26 09:54:26.000000Z):\nRT @rohan_2502: I built this app within 15 minutes. \n\nBackend API is built with @lemme_build which helped me to integrate the API with AI.…\n 0, url: https://twitter.com/aahiknsv/status/1828008092249784439\n\nTweet by Aayush_gupta_ji (2024-08-26 09:59:56.000000Z):\n@oliadukova @rootstock_io We are building a consumer dApp for the EthOnline Hackathon on Rootstock.\n\nDm'ed you more details about the dapp\n 1, url: https://twitter.com/Aayush_gupta_ji/status/1828009476324016564\n\nTweet by Aayush_gupta_ji (2024-08-26 10:03:48.000000Z):\nJai Shree Krishna\n 5, url: https://twitter.com/Aayush_gupta_ji/status/1828010447880028205\n\nTweet by AKSHITAAHLUWAL1 (2024-08-26 11:33:05.000000Z):\nHow do I explain that in Web3, the grind never stops? 😅 https://t.co/VHjv6M3v39\n 39, url: https://twitter.com/AKSHITAAHLUWAL1/status/1828032917982806104\n\nTweet by AKSHITAAHLUWAL1 (2024-08-26 11:44:17.000000Z):\n@bestmemecreator Yupp, Bumble Biz.\n 1, url: https://twitter.com/AKSHITAAHLUWAL1/status/1828035734462255341\n\nTweet by AKSHITAAHLUWAL1 (2024-08-26 11:45:24.000000Z):\n@adii_kris 😂😂lol\n 0, url: https://twitter.com/AKSHITAAHLUWAL1/status/1828036015858020780\n\nTwe" <> ..., "role" => "user"},
^%{"content" => "test", "role" => "user"},
^%{"content" => "It looks like you're testing. How can I assist you today?", "role" => "assistant"}
))}},
"SUCCESS", ~U[2024-08-28 20:27:33.417791Z], "f8258464-d951-4206-9284-df4d881086fd"]
↳ AshPostgres.DataLayer.update_query/4, at: lib/data_layer.ex:1380
as well as the error
** (MatchError) no match of right hand side value:
{:error, %Ash.Error.Unknown{
changeset: "#Changeset<>",
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for dynamic([], fragment(
\"(ARRAY[?,?,?,?])\",
^%{\"content\" => \"Default system prompt\", \"role\" => \"system\"},
^%{\"content\" => \"Here's a collection of tweets from the Twitter list 'Web 3 Mid':\\n\\n
Tweet by Aayush_gupta_ji (2024-08-26 05:08:32.000000Z):\\n
My simple PR is merged in @CyfrinUpdraft / @ProgrammerSmart DeFi course.\\n 16, url: https://twitter.com/Aayush_gupta_ji/status/1827936142785699862\\n\\n
Tweet by aahiknsv (2024-08-26 06:58:22.000000Z):\\n
Hellu cutiess!! \\n\\n
Who's interested in joining a live workflow-building session with @lemme_build tomorrow on Zoom?\\n\\n
Drop a comment!\\n 36, url: https://twitter.com/aahiknsv/status/1827963782745755873\\n\\n
Tweet by saminacodes (2024-08-26 07:13:06.000000Z):\\n
RT @SherzyOne: “If you had invested in Apple in 2007…”\\n\\n
Me in 07: https://t.co/DsGOkSfHkI\\n 0, url: https://twitter.com/saminacodes/status/1827967490997080094\\n\\n
Tweet by Aayush_gupta_ji (2024-08-26 07:13:23.000000Z):\\n
@uttam_singhk Sorry for your loss. \\n\\n
May God grant peace to his soul.\\n 1, url: https://twitter.com/Aayush_gupta_ji/status/1827967561729749368\\n\\n
Tweet by BhosalePratim (2024-08-26 07:19:13.000000Z):\\n
A big chunk of population(residing across the globe) needs to fix their scarcity mindset and stop getting jealous over the success of fellow Indians( or Indian origin people)\\n\\n
This mentality is hurting the whole community. \\n\\n
If things aren't working for you, take risks and get out of the rut.\\n\\n
I don't think @deedydas needs to answer to this dumb hate.\\n\\n
Congratulations on your green card @deedydas! And keep writing!\\n 16, url: https://twitter.com/BhosalePratim/status/1827969028842996159\\n\\n
Tweet by ThisisVanshika (2024-08-26 07:28:50.000000Z):\\n
@SuhailKakar Its definitely difficult! \\n
The amount of paperwork required for each single visa and every single year\\n 1, url: https://twitter.com/ThisisVanshika/status/1827971451607032157\\n\\n
Tweet by ThisisVanshika (2024-08-26 07:29:38.000000Z):\\n
@emceecoy_ gm\\n 1, url: https://twitter.com/ThisisVanshika/status/1827971650068856873\\n\\n
Tweet by dhaiwat10 (2024-08-26 07:30:20.000000Z):\\n
@grow_love @MichelleBakels Happy birthday Michelle!\\n 1, url: https://twitter.com/dhaiwat10/status/1827971827060056420\\n\\n
Tweet by saminacodes (2024-08-26 07:32:46.000000Z):\\n
RT @growing_daniel: Getting busy irl will make you realize how deeply and truly unreal twitter is\\n 0, url: https://twitter.com/saminacodes/status/1827972438354710689\\n\\n
Tweet by SuhailKakar (2024-08-26 07:51:33.000000Z):\\n
@imranfaststart @weneverleftt i'm down! my dms are open for all type of collaboration :)\\n 1, url: https://twitter.com/SuhailKakar/status/1827977168246173915\\n\\n
Tweet by SuhailKakar (2024-08-26 07:51:59.000000Z):\\n
@httpJunkie @Nikhil_Mahana at least, india's passport is much better than mine :)\\n 0, url: https://twitter.com/SuhailKakar/status/1827977275196780577\\n\\n
Tweet by edatweets_ (2024-08-26 09:42:44.000000Z):\\n
pretty cool that there are >180K basenames registered in less than a week. More than half paid 💰 https://t.co/fRJFjjsAai\\n 14, url: https://twitter.com/edatweets_/status/1828005148083273803\\n\\n
Tweet by aahiknsv (2024-08-26 09:54:26.000000Z):\\n
RT @rohan_2502: I built this app within 15 minutes. \\n\\n
Backend API is built with @lemme_build which helped me to integrate the API with AI.…\\n 0, url: https://twitter.com/aahiknsv/status/1828008092249784439\\n\\n
Tweet by Aayush_gupta_ji (2024-08-26 09:59:56.000000Z):\\n
@oliadukova @rootstock_io We are building a consumer dApp for the EthOnline Hackathon on Rootstock.\\n\\n
Dm'ed you more details about the dapp\\n 1, url: https://twitter.com/Aayush_gupta_ji/status/1828009476324016564\\n\\n
Tweet by Aayush_gupta_ji (2024-08-26 10:03:48.000000Z):\\n
Jai Shree Krishna\\n 5, url: https://twitter.com/Aayush_gupta_ji/status/1828010447880028205\\n\\n
Tweet by AKSHITAAHLUWAL1 (2024-08-26 11:33:05.000000Z):\\n
How do I explain that in Web3, the grind never stops? 😅 https://t.co/VHjv6M3v39\\n 39, url: https://twitter.com/AKSHITAAHLUWAL1/status/1828032917982806104\\n\\n
Tweet by AKSHITAAHLUWAL1 (2024-08-26 11:44:17.000000Z):\\n
@bestmemecreator Yupp, Bumble Biz.\\n 1, url: https://twitter.com/AKSHITAAHLUWAL1/status/1828035734462255341\\n\\n
Tweet by AKSHITAAHLUWAL1 (2024-08-26 11:45:24.000000Z):\\n
@adii_kris 😂😂lol\\n 0, url: https://twitter.com/AKSHITAAHLUWAL1/status/1828036015858020780\\n\\nTwe"
},
field: nil,
value: nil,
splode: Ash.Error,
bread_crumbs: [],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}
]
}}
this is VERY puzzling to me, as if I call the primary update action (the default one, with an accepts :* on it), I have 0 problems running this exact same data.
What is causing this to work on one action, but not the other?