larksuite/cli · error

Args field %s: flag %q is not a canonical flag name

Error message

Args field %s: flag %q is not a canonical flag name

What it means

A `flag` struct tag's name fails the canonical-flag-name rule enforced during collectArgFields; the flag would otherwise be mounted with an invalid CLI spelling.

Source

Thrown at shortcuts/common/typed_compile_args.go:131

				if inlineType.Kind() == reflect.Pointer {
					return fmt.Errorf("Args field %s: arg:\"inline\" must be a struct value, not pointer", field.Name)
				}
				if inlineType.Kind() != reflect.Struct {
					return fmt.Errorf("Args field %s: arg:\"inline\" must be a struct, got %s", field.Name, field.Type)
				}
				if hasAnyTag(field, "flag", "schema", "cli", "doc", "json") {
					return fmt.Errorf("Args field %s: arg:\"inline\" cannot declare public input tags", field.Name)
				}
				if err := collectArgFields(inlineType, index, true, out, seenGo, supplements); err != nil {
					return err
				}
			default:
				return fmt.Errorf("Args field %s: unknown arg mode %q", field.Name, argMode)
			}
			continue
		}
		if !flagNamePattern.MatchString(flagName) {
			return fmt.Errorf("Args field %s: flag %q is not a canonical flag name", field.Name, flagName)
		}
		if hasAnyTag(field, "json") {
			return fmt.Errorf("Args field %s (--%s): json tag is not allowed on a CLI field", field.Name, flagName)
		}
		valueType, valueIndex, isProvided, err := unwrapProvided(field.Type)
		if err != nil {
			return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
		}
		schema, err := parseSchemaTag(field.Tag.Get("schema"), valueType, true)
		if err != nil {
			return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
		}
		cli, err := parseCLITag(field.Tag.Get("cli"))
		if err != nil {
			return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
		}
		var shape typedValueShape
		supplement, hasSupplement := supplements[flagName]

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Rename the flag to canonical kebab-case in the tag
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/common/typed_compile_args.go:131 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/7eb6e1fb2fc524f9. Report an issue: GitHub.