Problem
Caddy.Admin.Api has inconsistent return contracts and silently swallows errors:
get/1, load/1, stop/0 return %{status: 0, body: nil} on failure
get_config/0,1, post_config, put_config, patch_config, delete_config return nil on failure
adapt/1 returns %{} on failure
health_check/0, get_metrics/1, server_info/0 return proper {:ok, _}/{:error, _} tuples
Callers are forced into fragile checks, e.g. map_size(json_config) > 0 in lib/caddy/server/external.ex:399.
Additional issues in the same module
load/1 with a map does a shallow Map.merge with the current config (lib/caddy/admin/api.ex:89) — surprising semantics that silently clobber nested keys
def api, do: nil (lib/caddy/admin/api.ex:51) is a dead placeholder holding a moduledoc
- ~400 lines of copy-pasted telemetry timing boilerplate — a single private
instrument/3 helper would cut the module by two-thirds
Proposal
Converge every function on tagged tuples. This is a breaking change — batch for a 3.0 release.
Problem
Caddy.Admin.Apihas inconsistent return contracts and silently swallows errors:get/1,load/1,stop/0return%{status: 0, body: nil}on failureget_config/0,1,post_config,put_config,patch_config,delete_configreturnnilon failureadapt/1returns%{}on failurehealth_check/0,get_metrics/1,server_info/0return proper{:ok, _}/{:error, _}tuplesCallers are forced into fragile checks, e.g.
map_size(json_config) > 0inlib/caddy/server/external.ex:399.Additional issues in the same module
load/1with a map does a shallowMap.mergewith the current config (lib/caddy/admin/api.ex:89) — surprising semantics that silently clobber nested keysdef api, do: nil(lib/caddy/admin/api.ex:51) is a dead placeholder holding a moduledocinstrument/3helper would cut the module by two-thirdsProposal
Converge every function on tagged tuples. This is a breaking change — batch for a 3.0 release.