Ash Framework

AF

Ash Framework

The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.

Join

support

showcase

today-i-learned

Mixing read action in `action_type` policy condition with other types; Error instead of filtering

Hi all, After upgrading to Ash 3.7.0 my tests for asserting that actions under policies requiring an actor being present started throwing Ash.Errors.Forbidden for read actions instead of just filtering and warning on :debug. ```elixir...
Solution:
@Carl please try main

Testing Spark Validator compilation warnings

I maintain some Ash Extensions that use Spark, and now have some ExUnit regression tests which used to assert_raise fine but now after upgrading ash deps for recent CVE spark also updated (2.2.68 to 2.3.5) and the Spark.Error.DslError's are no longer raised rather they are compile time warnings. I'd still like to test my Validators though, and there is no ExUnit.assert_warning. Likely that this has been encountered/solved some where in Ash already, what is the way forward here?...
Solution:
Yep, we were forced to make that change

Ash codegen and migrate `undefined_table` when I have `many_to_many`

Hi sorry, I hope I haven't missed anything. These are some of my resources that use has_many, but I'm getting an error with the tables. ```elixir defmodule MishkaBlog.BlogPost do postgres do table "mishka_blog_posts"...
Solution:
i think i am an idiot,

Graphql new type falls back to JsonString

Hello, I got a new type defined as: ``` defmodule ContactInfo do use Ash.Type.NewType, subtype_of: :map,...

how to flip a boolean with a builtin change

Is that possible? I don't see a way to get an attribute out with a dsl to do something like change set_attribute(:somebool, !attribute(:somebool))
Solution:
atomic_update(:somebool, expr(not somebool)) ?

`update_form` doesn't update params on root form

Im using the AshPhoenix.Form.update_form function to update a subform of the root form. If after the update_form I call a validate or update_params on the root form the params are reset to the values before the update_form call. Since a code snippet says more than 1000 words: ...

Vector issue

[error] Failed to update subtask embedding e28d6ac8-72da-4bd9-ad0e-cab51e25f3b9: %Ash.Error.Unknown{bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
[error] Failed to update subtask embedding 435405d4-317e-4b91-9b73-5fa23ecb88f8: %Ash.Error.Unknown{bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
[error] Failed to update subtask embedding 56a1c909-1d0c-4ad0-8e90-655fbd45cf3e: %Ash.Error.Unknown{bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
[error] Failed to update subtask embedding e28d6ac8-72da-4bd9-ad0e-cab51e25f3b9: %Ash.Error.Unknown{bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
[error] Failed to update subtask embedding 435405d4-317e-4b91-9b73-5fa23ecb88f8: %Ash.Error.Unknown{bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
[error] Failed to update subtask embedding 56a1c909-1d0c-4ad0-8e90-655fbd45cf3e: %Ash.Error.Unknown{bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], changeset: "#Changeset<>", errors: [%Ash.Error.Unknown.UnknownError{error: "** (FunctionClauseError) no function clause matching in Pgvector.new/1", field: nil, value: nil, splode: Ash.Error, bread_crumbs: ["Returned from bulk query update: ThalamusTasks.Tasks.SubTask.update"], vars: [], path: [], stacktrace: #Splode.Stacktrace<>, class: :unknown}]}
...

Upsert with partial unique index - WHERE clause support?

Hi everyone! I'm running into an issue with Ash's upsert functionality when dealing with a partial unique index. My table has a unique index defined as UNIQUE (org_id, name) WHERE org_id IS NULL, which is a partial index. The use case for this choice is that rows in the table can be scoped by tenant, or can be global (multitenancy with global? true)...

in an `after_action` `changeset.context` has no tenant?

So when you have something like: ```elixir def change(changeset, _opts, context) do Ash.Changeset.after_action(changeset, fn changeset, record ->...
Solution:
THey just aren't the same objects really

Timestamps getting updated unexpectedly

Hey I've got a pretty standard User resource backed by a users PG table and using AshAuthentication I'd seen some weirdness with users in the past and only just gotten some time to look into it...

parsing nested fields when argument is a TypedStruct

I have the following typed struct: ``` defmodule WeightRanker do use Ash.TypedStruct ...
Solution:
works on latest ash version

Does expressions support comparing datetimes, using the operators?

Can I use: ==, !=, >, >=, <, <= For comparing datetimes or do I need to use fragments?...

Implementing error for Forbidden.Policy removed all the helpful debug assistance :D

Following the helpful warning here:
This error was unhandled because Ash.Error.Forbidden.Policy does not implement the `AshPhoenix.FormData.Error` protocol.
This error was unhandled because Ash.Error.Forbidden.Policy does not implement the `AshPhoenix.FormData.Error` protocol.
...

Component attribute definition

Dear community. I have a component ```elixir attr :data, :any, required: true def whateven_chart(assigns) do...

%Protocol.UndefinedError{protocol: Enumerable, value: "5244d2cb-d104-4276-9c3b-1404995a6c1c", descri

``` [error] ChatProcessor: Fatal error processing conversation: %Protocol.UndefinedError{protocol: Enumerable, value: "5244d2cb-d104-4276-9c3b-1404995a6c1c", description: ""} [error] ChatProcessor: Stacktrace: (elixir 1.18.4) lib/enum.ex:1: Enumerable.impl_for!/1 (elixir 1.18.4) lib/enum.ex:166: Enumerable.reduce/3 (elixir 1.18.4) lib/enum.ex:4515: Enum.reduce/3...
No description

What is the best Practices for Handling Migrations in a Reusable Ash Library?

Hi sorry, Suppose you are building a library using Ash, and the main application that will use this library is also developed with Ash. This library needs to apply some migrations to the project's database (has resources). I'm wondering what the best approach would be in this case. Should we add a migration to the main Phoenix project, similar to how Oban does it? Or is there a better way to handle this in Ash? Also, keep in mind that this library is expected to have new resources (and thus new migrations) added in the future....
Solution:
Not possible right now

How can I bypass or re-evaluate multi-tenancy for specific aggregates?

I have an aggregate for Count, but the problem is that it conflicts with the structure of the application when it comes to multi-tenancy. The relevant code looks like this: JsonAPI ```elixir aggregates do count :media_count, :media do public? true...
Solution:
I don't believe that we have an option to bypass multitenancy for aggregates or calculations that use aggregates. You'll need to open an issue.

Showing paginated data inside generic actions, works in normal call but i can not show in json

Hi my friends, Since my application's structure includes two types of users — one group being masters (who don't have a site_id and have access to everything), and the other group being regular users (who do have a site_id and can only access their own data) — this setup has led to a few challenges for me. The main issue I'm facing due to this structure is that I often need to create generic actions. Unfortunately, I'm running into two major problems with this approach:...
Solution:
its not much money but we aren't loaded 😆

Multi-level Hierarchy Beyond Native Multitenancy - Need Guidance

Building an e-commerce platform with a 4-level hierarchy:
Sudo → Tenant → Seller → Stores
Sudo → Tenant → Seller → Stores
...

IP based rate limiting with ash_graphql

I'm trying to implement ash_rate_limiter with ash_graphql. For all the resources I have that require an actor to access them, this is great, I can setup a key based on the user's ID or something just like in the ash_rate_limiter docs, and we're golden. But, for endpoints such as a create user endpoint, I want to be able to rate limit by IP, since there's no actor in play yet. I assume I need to find some way to wire up a plug that grabs the user's IP out of the conn and sets it somewhere in some context that gets passed through to the rate limiter config, but I'm a little unsure the best way to set this up with ash_graphql....
Solution:
We're actually adding a plug as part of https://github.com/team-alembic/ash_authentication/pull/1074 that stores the connection information in the shared context for later. Until that lands you can make a plug that does the same thing and add it to your graphql pipeline. From there it's a simple matter of modifying your key function to take this into account.