Invalid association, not an ecto schema

michaelst57
2023-07-04

michaelst57:

I’m getting a strange compile error that I can’t replicate locally, only in GitHub Actions, I’m on the latest version of everything, ash deps, elixir and erlang.

==> spendable
Compiling 5 files (.ex)
warning: invalid association `budget` in schema Spendable.BudgetAllocation: associated module Spendable.Budget is not an Ecto schema
Warning:   lib/spendable/resources/budget_allocation.ex:1```

I'm not sure what would be different in GitHub Actions to cause this, any ideas where to look?

zachdaniel:

My guess would be that it’s an elixir version thing

zachdaniel:

What version are you on in CI vs locally?

michaelst57:

Both 1.15.2, I noticed it is also happening in docker builds

zachdaniel:

🤔🤔🤔what about OTP version?

michaelst57:

26.0.2, also same on both

zachdaniel:

Strange

zachdaniel:

Still can’t reproduce it locally? What if you blow away your build directory locally and recompile?

michaelst57:

yep still not happening locally, but even then the error doesn’t make any sense, what would trigger that

zachdaniel:

It would be some kind of compilation order/dependency issue

zachdaniel:

(not a mix dependency but module compilation dependency)

zachdaniel:

The ecto schema we build under the hood doesn’t think the other resources we add as associations are also ecto schemas for some reason

michaelst57:

in case you want to play with it this project is open source https://github.com/michaelst/spendable , seems to be happening consistently in the tests in CI

michaelst57:

actually whatever changes I have made in my uuid migration got rid of it…

Eduardo B. Alexandre:

I’m having the exact same problem and I can’t figure out a solution for it. <@785010366785519696> can you elaborate more on what you changed?

michaelst57:

The error actually came back, I think it is the order like Zach was mentioning

zachdaniel:

I should have fixed it on latest ash

Eduardo B. Alexandre:

I’m not in the latest version, I will try updating it and see if that works

Eduardo B. Alexandre:

Yep, updating to the latest version fixed it, thanks <@197905764424089601> ! <@785010366785519696> probably doing the same will fix it for you as-well

michaelst57:

Thanks!

\ ឵឵឵:

Fix or related to https://github.com/ash-project/ash/issues/557 ?

zachdaniel:

good call, thats fixed now