moxley

moxley

Troubleshooting authorization error through ash_graphql

After updating ash from version 2.17.11 to 2.17.12, 9 test failures showed up in my test suite. All the failures were on API tests that use ash_graphql. I’m on ash_graphql 0.25.13. All the failures are the same: the response contains the "message": "forbidden" error, the kind you get when the actor doesn’t have permission to access something. The logs did not contain any policy breakdown (it seems never to work during ash_graphql tests).

These are all the log entries that are logged for a failing test:

20:00:26.004 request_id=F8qg_y1LnSpDpzwAAA2B [info] POST /api/gql
20:00:26.029 request_id=F8qg_y1LnSpDpzwAAA2B [info] GF.Carts.PaymentMethodInput.create
20:00:26.029 request_id=F8qg_y1LnSpDpzwAAA2B [info] Sent 200 in 24ms

My config/test.exs contains this :ash, :policies entry:

config :ash, :policies,
  show_policy_breakdowns?: true,
  log_policy_breakdowns: :info,
  log_successful_policy_breakdowns: :debug

When changing it to log_policy_breakdowns: :warning, this log entry changes from an info to a warning level:

20:00:26.029 request_id=F8qg_y1LnSpDpzwAAA2B [warning] GF.Carts.PaymentMethodInput.create

I tried bypassing ash_graphql, writing a test that only calls Ash.Changeset and my Ash API module, but there was no authorization error, and I’m not sure I’m setting it up the same way that ash_graphql is.

Without a policy breakdown, and no details in the logs, how does one go about troubleshooting this issue?

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Yeah, that is some low hanging fruit DX that should have been addressed a long time ago. Will look into it today :slight_smile:

Also Liked

moxley

moxley

I figured it out. It was related to that log entry I mentioned before, for GF.Carts.PaymentMethodInput.create. GF.Carts.PaymentMethodInput is an embedded resource. It had Ash.Policy.Authorizer configured as the authorizer, but there were no policies configured in that resource, nor should there be. By removing Ash.Policy.Authorizer from the resource configuration, the errors went away.

I would have been helpful if the logs indicated that no policies were set.

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement