larksuite/cli · error

Output.Mode %q is invalid

Error message

Output.Mode %q is invalid

What it means

Thrown when Output.Mode in a typed shortcut definition is neither the generic output mode nor the fixed-JSON mode. The compiler accepts only these two whitelisted modes; any other string (typo, new value, empty) is rejected.

Source

Thrown at shortcuts/common/typed_compile_contract.go:92

				}
				if fields[fieldIndex].cli.Hidden {
					return fmt.Errorf("%s references hidden param --%s; use a public canonical param", path, param)
				}
				if _, duplicate := seen[param]; duplicate {
					return fmt.Errorf("%s.Params contains duplicate param --%s", path, param)
				}
				seen[param] = struct{}{}
			}
		}
	}
	return nil
}

func validateOutput(definition typedOutputDefinition, dataShape typedValueShape) error {
	switch definition.Mode {
	case typedOutputGeneric, typedOutputFixedJSON:
	default:
		return fmt.Errorf("Output.Mode %q is invalid", definition.Mode)
	}
	return nil
}

func decodeJSONPointerSegment(segment string) (string, bool) {
	var builder strings.Builder
	for index := 0; index < len(segment); index++ {
		if segment[index] != '~' {
			builder.WriteByte(segment[index])
			continue
		}
		if index+1 >= len(segment) {
			return "", false
		}
		index++
		switch segment[index] {
		case '0':
			builder.WriteByte('~')

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Set Output.Mode to the exported constant (typedOutputGeneric or typedOutputFixedJSON) rather than a raw string
  2. Check the allowed values via --help or schema output for the definition surface
  3. Remove the Mode field if generic output is intended

Example fix

// before
Output: OutputDefinition{Mode: "json"}
// after
Output: OutputDefinition{Mode: typedOutputFixedJSON}
Defensive patterns

Strategy: validation

Validate before calling

switch def.Output.Mode {
case "", common.TypedOutputGeneric, common.TypedOutputFixedJSON:
default:
  return fmt.Errorf("unsupported Output.Mode %q", def.Output.Mode)
}

Type guard

func validOutputMode(m string) bool {
  return m == common.TypedOutputGeneric || m == common.TypedOutputFixedJSON
}

Try / catch

if err := common.CompileTypedDefinition(def); err != nil {
  return fmt.Errorf("invalid output mode: %w", err)
}

Prevention

When it happens

Trigger: typedOutputDefinition with Mode set to e.g. "json", "table", "fixed_json", or "" instead of the exact typedOutputGeneric or typedOutputFixedJSON constants.

Common situations: Hand-writing the mode string instead of using the exported constant; assuming a mode name from another CLI; upgrading a definition after mode constants changed.

Related errors


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