Skip to content

ARCE0001: A module declares a schema and handle/2 but does not use Arc.Command

Kind: module. Default severity: warning. The .NET counterpart is ARC0002.

Arc discovers commands by their use Arc.Command. A module with an Arc.Schema and a handle/2 function looks like a command, so when it does not use Arc.Command, the author almost certainly forgot to. Nothing fails; the command is just never routed, never validated and never in the generated proxies.

The mistake is silent. The module compiles, its own tests may even pass when they call handle/2 directly, and the failure appears as a 404 from the client.

defmodule MyApp.Authors.Registration.RegisterAuthor do
use Arc.Schema
schema do
field :id, :uuid, key: true, required: true
field :name, :string, required: true
end
def handle(%__MODULE__{} = command, _ctx),
do: {:append, %MyApp.Authors.AuthorRegistered{name: command.name}}
end

use Arc.Command includes use Arc.Schema, so replace it:

defmodule MyApp.Authors.Registration.RegisterAuthor do
use Arc.Command
schema do
field :id, :uuid, key: true, required: true
field :name, :string, required: true
end
def handle(%__MODULE__{} = command, _ctx),
do: {:append, %MyApp.Authors.AuthorRegistered{name: command.name}}
end
  • If the module is a command, replace use Arc.Schema with use Arc.Command.
  • If it is not a command, rename handle/2, for example to process/2.
  • If the shape is deliberate, switch the rule off for the module with @arc_analyzer ignore: ["ARCE0001"].