larksuite/cli · error

.Params[ ] must be a non-blank trimmed param

Error message

%s.Params[%d] must be a non-blank trimmed param

What it means

Thrown when a param entry in Authorization conditional scopes is empty or has leading/trailing whitespace. Param names must be non-blank and trimmed so they can be matched exactly against compiled input fields.

Solutions

  1. Trim whitespace or remove the blank entry from Params
  2. strings.TrimSpace each element when params are derived from user-supplied config

Example fix

// before
Params: strings.Split("--chat-id, --message-id", ",") // ["--chat-id", " --message-id"]
// after
Params: []string{"--chat-id", "--message-id"} // pre-trimmed literals
Defensive patterns

Strategy: validation

Validate before calling

for j, p := range cs.Params {
  if strings.TrimSpace(p) == "" || p != strings.TrimSpace(p) {
    return fmt.Errorf("param %d must be trimmed and non-blank", j)
  }
}

Try / catch

if err := common.CompileTypedDefinition(def); err != nil {
  return fmt.Errorf("untrimmed param in conditional scopes: %w", err)
}

Prevention

When it happens

Trigger: ConditionalScopes entry with Params containing "" or " --doc-id " (untrimmed).

Common situations: Building param lists from split strings without trimming; placeholder empty strings left in scaffolding; trailing comma/space artifacts in hand-edited slices.

Related errors


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

Appendix: source

Thrown at shortcuts/common/typed_compile_contract.go:69

			return nil, fmt.Errorf("Input.Relations[%d] duplicates an earlier relation", i)
		}
		seen[key] = struct{}{}
		result = append(result, compiled)
	}
	return result, nil
}

func compileAuthorization(definition typedAuthorizationDefinition, fields []compiledInputField, fieldByName map[string]int) error {
	for identity, authorization := range definition.Identities {
		for i, conditional := range authorization.ConditionalScopes {
			path := fmt.Sprintf("Authorization.%s.ConditionalScopes[%d]", identity, i)
			if len(conditional.Params) > 0 && conditional.When == "" {
				return fmt.Errorf("%s.Params requires agent-readable When text", path)
			}
			seen := make(map[string]struct{}, len(conditional.Params))
			for j, param := range conditional.Params {
				if param == "" || param != strings.TrimSpace(param) {
					return fmt.Errorf("%s.Params[%d] must be a non-blank trimmed param", path, j)
				}
				fieldIndex, ok := fieldByName[param]
				if !ok {
					return fmt.Errorf("%s references unknown param --%s", path, param)
				}
				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
}

View on GitHub (pinned to 7fd6ef3c07)