ARCE0002: A command or query is both anonymous and restricted
Kind: module. Default severity: error. The .NET counterpart is ARC0019.
A declaration that sets allow_anonymous: true together with roles:, policy: or authenticated: contradicts itself. Arc checks allow_anonymous first and lets the caller through, so the restriction is silently ignored. The rule checks the module-level authorize of a command or read model and the authorize: option of each @query and @observe.
Why it matters
Section titled “Why it matters”The author wrote a restriction and believes it holds. It does not: the command or query is open to everyone. This is an access control mistake, which is why it defaults to an error.
defmodule MyApp.Authors.Registration.RemoveAuthor do use Arc.Command
authorize allow_anonymous: true, roles: ["admin"]
# ...end@query authorize: [allow_anonymous: true, policy: :can_list]def all_authors(_args, _ctx), do: # ...Keep the one you mean:
authorize roles: ["admin"]@query allow_anonymous: truedef all_authors(_args, _ctx), do: # ...A query may legitimately differ from its module: @query allow_anonymous: true inside a module that says authorize roles: [...] overrides the module for that query, and is not reported.
How to fix
Section titled “How to fix”Decide who may call it and delete the other half of the declaration.
Related rules
Section titled “Related rules”- Authorization and identity explains how requirements are checked.