larksuite/cli · error

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

Error message

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

What it means

validateRawTypes, the batch dispatcher's standalone-parity check: a JSON-typed flag value for a boolean flag is not bool. Standalone cobra would reject it at parse time; the batch JSON path rejects it here so both entry points behave alike.

Source

Thrown at shortcuts/sheets/flag_view.go:315

		switch typ {
		case "int":
			// Int(): float64 → int(t) truncates, so a non-integer number would
			// be silently floored (1.9 → 1). Standalone cobra rejects it at
			// parse time; reject here too to keep batch/standalone parity.
			f, isNum := val.(float64)
			if !isNum {
				return fmt.Errorf("--%s must be a number, got %s", name, jsonTypeName(val)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
			}
			if math.Trunc(f) != f {
				return fmt.Errorf("--%s must be an integer, got %s", name, strconv.FormatFloat(f, 'g', -1, 64)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
			}
		case "float64":
			if _, isNum := val.(float64); !isNum {
				return fmt.Errorf("--%s must be a number, got %s", name, jsonTypeName(val)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
			}
		case "bool":
			if _, isBool := val.(bool); !isBool {
				return fmt.Errorf("--%s must be a boolean, got %s", name, jsonTypeName(val)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error
			}
		}
	}
	return nil
}

// normalizeAndValidateEnums applies the same flat string-enum contract as the
// standalone cobra path. Canonical casing and known aliases are rewritten in
// place; unknown values are rejected before a translator can silently fall
// back to a different operation.
func (m *mapFlagView) normalizeAndValidateEnums() error {
	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

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Pass true/false for boolean flags in batch JSON
Defensive patterns

Strategy: validation

When it happens

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