larksuite/cli · error

%s does not match any allowed shape

Error message

%s does not match any allowed shape

What it means

A field declared with a oneOf shape constraint must match at least one of its declared variants; when the supplied JSON value matches none, the validator returns this error naming the failing path. It is thrown by validateJSONValueAgainstShape while checking values against compiled shape constraints.

Source

Thrown at shortcuts/common/typed_binder.go:394

		return typedFieldValidation(field, "cannot be represented as JSON: %v", err).WithCause(err)
	}
	if err := validateJSONValueAgainstShape(jsonValue, field.shape, "value"); err != nil {
		return typedFieldValidation(field, "%v", err).WithCause(err)
	}
	return nil
}

func validateJSONValueAgainstShape(value any, shape typedValueShape, path string) error {
	switch constraint := shape.(type) {
	case anyJSONShape:
		return nil
	case typedOneOfShape:
		for _, variant := range constraint.Variants {
			if err := validateJSONValueAgainstShape(value, variant, path); err == nil {
				return nil
			}
		}
		return fmt.Errorf("%s does not match any allowed shape", path)
	case typedNullShape:
		if value != nil {
			return fmt.Errorf("%s must be null", path)
		}
		return nil
	case typedConstShape:
		expectedJSON, err := json.Marshal(constraint.Value)
		if err != nil {
			return fmt.Errorf("%s has invalid const: %w", path, err)
		}
		expected, err := decodeJSONValidationValue(expectedJSON)
		if err != nil {
			return fmt.Errorf("%s has invalid const: %w", path, err)
		}
		if !reflect.DeepEqual(value, expected) {
			return fmt.Errorf("%s must equal %v", path, constraint.Value)
		}
		return nil

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Inspect the schema (schema command / compiled constraint.Variants) and pick a value matching one listed variant exactly.
  2. Fix the field's type/shape — e.g. wrap the scalar in the expected object.
  3. If the schema is wrong (missing a legitimate variant), update the shape definition to include it.

Example fix

// before
params.Set("owner", "team-x") // oneOf: [object, null]

// after
params.Set("owner", map[string]any{"id": 12345})
Defensive patterns

Strategy: validation

Validate before calling

// verify the value matches at least one oneOf variant before binding
for _, v := range variants {
    if valueCompatibleWithShape(candidate, v, path) == nil { return true }
}
return false

Try / catch

if err := binder.Set("owner", val); err != nil {
    if strings.Contains(err.Error(), "does not match any allowed shape") {
        return fmt.Errorf("owner must be one of the documented shapes: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Supplying a value for a field whose schema is typedOneOfShape (e.g. string-or-object, or an enum of number ranges) that fails every variant — e.g. a plain string where variants require an object or a numeric id.

Common situations: Developers misread polymorphic API fields: sending {"user": "abc"} when the schema allows {"user": {"id": 12345}} or {"user": null}; or sending a list where only scalar/object variants are allowed.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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