larksuite/cli · error

--%s must be a string, got %s

Error message

--%s must be a string, got %s

What it means

Guard in normalizeAndValidateEnums: a batch-op raw value for a string enum flag is not a JSON string; typed enumeration validation requires string input. Intermediate error wrapped by the batch dispatcher.

Source

Thrown at shortcuts/sheets/flag_view.go:345

	defs, err := loadFlagDefs()
	if err != nil {
		return nil //nolint:nilerr // match validateRawTypes: missing embedded metadata must not block the batch
	}
	spec, ok := defs[m.command]
	if !ok {
		return nil
	}
	for _, df := range spec.Flags {
		if df.Kind == "system" || df.Type != "string" || len(df.Enum) == 0 {
			continue
		}
		rawKey, raw, changed := m.lookupRawWithKey(df.Name)
		if !changed {
			continue
		}
		value, ok := raw.(string)
		if !ok {
			return fmt.Errorf("--%s must be a string, got %s", df.Name, jsonTypeName(raw)) //nolint:forbidigo // intermediate error; batch dispatcher adds typed operations context
		}
		if value == "" || slices.Contains(df.Enum, value) {
			continue
		}
		if canonical := canonicalEnumValue(value, df.Enum); canonical != "" {
			m.raw[rawKey] = canonical
			continue
		}
		// A retired value means "as if omitted" — delete the key so Changed()
		// also reports it as absent, matching the standalone path.
		if isRetiredEnumValue(m.command, df.Name, value) {
			delete(m.raw, rawKey)
			continue
		}
		message := fmt.Sprintf("invalid value %q for --%s, allowed: %s", value, df.Name, strings.Join(df.Enum, ", "))
		if match := closestEnumValue(value, df.Enum); match != "" {
			message += fmt.Sprintf("; did you mean %q?", match)
		}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Pass the value as a JSON string
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shortcuts/sheets/flag_view.go:345 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/3a4c2eea1a66de75. Report an issue: GitHub.