New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning when consolidating Inspect protocol with redacted fields #3464
Comments
I've initally opened a thread with this behaviour in ElixirForum since I didn't know if it was a bug or I had something wrong in my code. As can bee seen in the responses other people seems to experience the same problem, so I've decided to open it as an issue here. |
Do you see the warning only on ElixirLS? If so, which Elixir LS version are you using? Notice there is a fork which is more recently updated. Please let me know if the issue persists there too. |
I am using the following ElixirLS, which I believe is the latest one after the fork was merged with the "official" extension:
|
Ah, the fork has been deprecated. I am behind the times. :) @msaraiva, can you reproduce this? |
@josevalim I can reproduce it one of my projects on elixirLS but not in mix. This particular project does not depend on ecto so I believe it's a generic issue. The code that generates this warning defines a protocol and many structs implementing it with |
I've tried some previous versions of ElixirLS (0.50 and 0.40) and I can reliably reproduce this behaviour in both of them. I am unsure about how to debug this, but if we all agree that this seems to be a ElixirLS bug maybe I should move this issues to their repository. |
I am using VSCode with ElixirLS, but I always run an embedded terminal with I get the error once per redacted field in the iex session. For example, I have a schema with 2 redacted fields, and I get 2 back-to-back warnings. Like so:
As far as I can tell, I don't get the error in ElixirLS. I am looking at the "output" screen in VSCode and see no reference to the warning. I attempted to disable consolidation but the warnings still appear. Am I misunderstanding something about this option?:
|
The fact you can reproduce it without ElixirLS is great. Any chance you isolate it to a small project that you can share so I take a look? And to be double sure... you are not manually implementing inspect for these schemas, right? |
@sb8244 @josevalim I can reproduce the behaviour in the example project provided in the issue description. Steps:
|
This is a Phoenix bug. I have pushed a fix to Phoenix v1.5 and master branches. Please give one of them a try and let me know if you find anything else, thanks! |
In my case I tested with the For reference I only did Thanks for the quick fix José! |
For future reference this appears to be the commit that fixes this issue: phoenixframework/phoenix@b5580e9 |
I can confirm that the bug is fixed in Phoenix master 👍 I can not reproduce it anymore with the example repository for this bug. |
I wasn't sure where to post this issue, but google led me here and I'm hoping it's ok. I'm noticing this issue after upgrading to Elixir $ mix xref trace lib/ros/accounts/user.ex
> warning: the Inspect protocol has already been consolidated, an implementation for Ros.Accounts.User has no effect. If you want to implement protocols after compilation or during tests, check the "Consolidation" section in the Protocol module documentation
lib/ros/accounts/user.ex:11: Ros.Accounts.User (module) The code looks like this: 10 @derive {Inspect, except: [:password]}
11 schema "users" do
I've read the referenced section and it's unclear to me if this is an actual issue or if I can safely ignore it. Has anyone here experienced this issue recently? I ran |
Can you please open up an issue in Elixir? This is safe but we should either document this in |
Environment
Current behavior
Creating a schema with a redacted field causes a warning when the project is compiled by ElixirLS. I've first encountered this problem in a personal project and was able to track it down to the
redacted: true
property on the field.I've created an example repository to reproduce this behaviour. After loading the project, any change done in the
EctoWarningExample.User
module that triggers a recompilation will cause this warning to appear in ElixirLS. This can be tested simply by adding a new blank line into the module.I've taken a look into the Ecto code and found this. It looks like Ecto is deriving the Inspect protocol for this schema to avoid showing the redacted field. What I don't really know is where is the other implementation for the same protocol which is triggering the warning.
Screenshot of the warning in VSCode with ElixirLS
The warning message itself
Expected behavior
The code should compile cleanly without warnings.
The text was updated successfully, but these errors were encountered: