Skip to content

Clarifying the caddyfile.Dispenser.ArgErr() documentation #7959

Closed

Description

@ParsaJR

Issue Details

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:

https://github.com/caddy-dns/template/blob/b7d83aa532083123446030f9fb1c8361767e80c9/module.go#L47

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.

No response

Activity

  1. changed the title [-]Clarifying `caddyfile.Dispenser.ArgErr()` documentation[/-] [+]Clarifying the `caddyfile.Dispenser.ArgErr()` documentation[/+] on Aug 24, 2026
  2. added
    documentation 📚
    good first issue 🐤
    on Aug 25, 2026
  3. steadytao commented on Aug 25, 2026

    @steadytao
    Member

    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.

  4. 0jaspahwa commented on Aug 25, 2026

    @0jaspahwa
    Contributor

    I'd like to take this one.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation 📚good first issue 🐤

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions