belaustegui

belaustegui

"The Inspect protocol has already been consolidated" for Ecto schema with redacted field

I’ve recently started a new Phoenix project using Elixir 1.11, Phoenix 1.5 and Ecto 3.5.

Everything runs smoothly but there is a recurrent warning in ElixirLS which I can not fix. The warning says:

the Inspect protocol has already been consolidated, an implementation for MyApp.User has no effect. If you want to implement protocols after compilation or during tests, check the “Consolidation” section in the Protocol module documentation

The warning is highlighted in the Ecto schema declaration:

The thing is: the module does not implement the Inspect protocol. I know I can disable protocol consolidation in development to make this warning disappear, but I would like to know what is causing it. It only happens in this schema and not in the resto of Ecto schemas I have implemented.

EDIT

I’ve dived into the Ecto.Schema.schema() code and found this code which I belive is causing the warning:

        if redacted_fields != [] and not List.keymember?(@derive, Inspect, 0) and
             @ecto_derive_inspect_for_redacted_fields do
          @derive {Inspect, except: @ecto_redact_fields}
        end

My schema has a field :password, :string, virtual: true, redact: true which triggers this code and derives the Inspect protocol for my schema.

So, now that I know where this comes from. Is there a way to fix this warning? Should I report it as a bug in Ecto?

Most Liked

zac

zac

I’m running into the same issue with a simple (demo) Ash Framework project. As soon as I added more than the basic persistence, started seeing:

warning: the Inspect protocol has already been consolidated, an implementation for Helpdesk.Support.Ticket has no effect. If you want to implement protocols after compilation or during tests, check the "Consolidation" section in the Protocol module documentation
  lib/helpdesk/support/resources/ticket.ex:1

The code is pretty simple:

defmodule Helpdesk.Support.Ticket do
  use Ash.Resource

  actions do
    defaults [:create, :read, :update, :destroy]

    create :open do
      accept [:subject]
    end
  end

  attributes do
    uuid_primary_key :id

    attribute :subject, :string do
      allow_nil? false
    end

    attribute :status, :atom do
      constraints [one_of: [:open, :closed]]
      default :open
      allow_nil? false
    end
  end
end
lukaszsamson

lukaszsamson

ElixirLS Core Team

ElixirLS bug is already fixed on master

i-n-g-m-a-r

i-n-g-m-a-r

Was this fixed?
Probably it was, the bug seems to have returned.

belaustegui

belaustegui

I’ve opened an issue in Ecto repository with an example project that can be used to reproduce this warning.

belaustegui

belaustegui

The bug has been resolved in Phoenix, which does not report the warning anymore. ElixirLS is not fixed yet and keeps showing the warning just like before.

This is the issue tracking that bug in the ElixirLS repository.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement