How to solve "(Jason.DecodeError)" in Ash Authentication Phoenix tutorial
Hi everyone, I am going through the Ash Authentication Tutorial but I'm stuck on an obtuse error that gives me few clues where to debug it:
It looks like there is an error with a JSON file somewhere but I cannot tell which JSON file it should be and/or how I could find out. Can anyone give any pointers as to how to debug this?
Sorry, I am quite a beginner in Elixir/Phoenix/Ash so I apologize if this has quite an obvious solution. I would just like to understand where to start fixing this.
Ash HQ
Guide: Getting Started With Ash Authentication Phoenix
Read the "Getting Started With Ash Authentication Phoenix" guide on Ash HQ
3 Replies
🤔 that is pretty strange!
The issue is likely in one of the json snapshots in your priv directory.
Not sure how, but it looks like you’ve got invalid json in one of those files. My suggestion would be, if you’re just getting started on the tutorial, is to delete your migrations and snapshots (everything in priv/repo/migrations and the accompanying snapshots folder, as well as the extensions snapshot) and then regenerate
I’m on my phone so I don’t remember the exact file/folder names. But to regenerate you’d do
mix ash_postgres.generate_migrations
And it will get you up to current including the changes for the ash authentication guide you’re working on.
May need to throw in a mix do ash_postgres.drop, ash_postgres.create, ash_postgres.migrate
in there for good measure to clean things up (this deletes and recreates the database for that app)Hi @Zach Daniel thanks for your extensive answer! Much appreciated.
1.
rm -rf priv/repo/migrations && rm -rf priv/resource_snapshots/
did fix the mix ash_postgres.generate_migrations --name add_user_and_token
command and I was able to migrate after issuing your mix do ash_postgres.drop, ash_postgres.create, ash_postgres.migrate
command. Thanks!
2. If this is relevant FYI, there is only one very short json file extensions.json
in priv/resource_snapshots/extensions.json
, but it looks like valid json:
thank you for your help!🤔 quite strange! That does indeed look like valid JSON
Well, if it happens again LMK! For now I think we'll call it bad luck 😆