You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarifying the caddyfile.Dispenser.ArgErr() documentation #7959
When implementing a Caddyfile parser in custom Caddy modules, it's common to call the method caddyfile.Dispenser.ArgErr() when an argument in current line is somehow invalid.
Now, i believe the documentation for caddyfile.Dispenser.ArgErr() is somewhat misleading because it describes only the case where an argument is expected but missing.
The current documentation says:
// ArgErr returns an argument error, meaning that another// argument was expected but not found. In other words,// a line break or open curly brace was encountered instead of// an argument.func (d*Dispenser) ArgErr() error {
--snip--
}
ArgErr returns an argument error, meaning that another argument was expected but not found.
However, ArgErr() is also commonly used when an argument is unexpected.
This is what i encounter when i was looking at the caddy.dns template here:
In general, i think the current wording can be confusing when implementing a Caddyfile parser because it suggests that ArgErr() method is specifically means that an argument was expected but missing. While i suppose it's also used by people in the other way around.
Assistance Disclosure
AI not used
If AI was used, describe the extent to which it was used.
changed the title [-]Clarifying `caddyfile.Dispenser.ArgErr()` documentation[/-][+]Clarifying the `caddyfile.Dispenser.ArgErr()` documentation[/+]on Aug 24, 2026
Please leave to new contributors for at least 1 week. ArgErr represents an invalid argument count which includes both a missing required argument and an unexpected extra argument. A present argument with an invalid value should still use Errf or SyntaxErr. This should only require a relatively small docs update.
Plan: reword the ArgErr doc comment to say it covers a wrong number of arguments, either a missing one or an extra one, and add a line noting that an argument that's present but has a bad value should use Errf or SyntaxErr instead. Docs only, no code change.
Assistance disclosure: used Claude to help navigate the codebase. I'll write and verify the change myself.
Activity
[-]Clarifying `caddyfile.Dispenser.ArgErr()` documentation[/-][+]Clarifying the `caddyfile.Dispenser.ArgErr()` documentation[/+]steadytao commentedon Aug 25, 2026
Please leave to new contributors for at least 1 week. ArgErr represents an invalid argument count which includes both a missing required argument and an unexpected extra argument. A present argument with an invalid value should still use Errf or SyntaxErr. This should only require a relatively small docs update.
0jaspahwa commentedon Aug 25, 2026
I'd like to take this one.
Plan: reword the
ArgErrdoc comment to say it covers a wrong number of arguments, either a missing one or an extra one, and add a line noting that an argument that's present but has a bad value should useErrforSyntaxErrinstead. Docs only, no code change.Assistance disclosure: used Claude to help navigate the codebase. I'll write and verify the change myself.