larksuite/cli · error
%s.Requirement %q is invalid
Error message
%s.Requirement %q is invalid
What it means
The compiler only accepts two values for a ConditionalScopes entry's Requirement field: typedScopeRequired and typedScopeBestEffort. Any other string (including typos or casing variants) makes validateCommandMetadata reject the declaration.
Source
Thrown at shortcuts/common/typed_compiler.go:150
path := fmt.Sprintf("Authorization.%s.ConditionalScopes[%d]", identity, i)
if err := validateScopeList(conditional.Scopes, path); err != nil {
return err
}
if len(conditional.Scopes) == 0 {
return fmt.Errorf("%s.Scopes is empty", path)
}
for _, scope := range conditional.Scopes {
if _, alwaysRequired := requiredScopes[scope]; alwaysRequired {
return fmt.Errorf("%s scope %q is already always required for identity %q", path, scope, identity)
}
}
if conditional.When != strings.TrimSpace(conditional.When) {
return fmt.Errorf("%s.When must be trimmed", path)
}
switch conditional.Requirement {
case typedScopeRequired, typedScopeBestEffort:
default:
return fmt.Errorf("%s.Requirement %q is invalid", path, conditional.Requirement)
}
}
}
if len(metadata.Authorization.IdentityOrder) > 0 {
if len(metadata.Authorization.IdentityOrder) != len(metadata.Authorization.Identities) {
return fmt.Errorf("Metadata.Authorization.IdentityOrder must contain each declared identity exactly once")
}
seen := make(map[typedIdentity]struct{}, len(metadata.Authorization.IdentityOrder))
for _, identity := range metadata.Authorization.IdentityOrder {
if _, ok := metadata.Authorization.Identities[identity]; !ok {
return fmt.Errorf("Metadata.Authorization.IdentityOrder contains undeclared identity %q", identity)
}
if _, duplicate := seen[identity]; duplicate {
return fmt.Errorf("Metadata.Authorization.IdentityOrder contains duplicate identity %q", identity)
}
seen[identity] = struct{}{}
}
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Replace the literal with the exported constant (e.g. common.TypedScopeRequired or common.TypedScopeBestEffort)
- If a literal is required, copy the exact constant value including casing
- Leave Requirement empty to get the default (required) via normalization
Example fix
// before Requirement: "required", // after Requirement: common.TypedScopeRequired,
Defensive patterns
Strategy: validation
Validate before calling
req := c.Requirement
if req != "" && req != common.TypedScopeRequired && req != common.TypedScopeBestEffort { return fmt.Errorf("invalid Requirement %q", req) } Prevention
- Use the exported constants instead of string literals
- Rely on the empty-string default (required) rather than guessing values
- Grep the codebase for existing Requirement usages when unsure of accepted values
When it happens
Trigger: Setting ConditionalScopes[i].Requirement to something other than the two accepted constants, e.g. "required" (lowercase), "optional", or "Required".
Common situations: Typing the literal string instead of using the exported constant; refactoring that renamed constants; assuming an empty string works (note: normalization at typed_compiler.go:77 fills empty Requirement with typedScopeRequired, so this error means a non-empty wrong value was set).
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
- %s.When must be trimmed
- %s[%d] must be a non-blank trimmed scope
- %s contains duplicate scope %q
- Metadata.Authorization.IdentityOrder must contain each decla
- Metadata.Authorization.IdentityOrder contains undeclared ide
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/1f559ce0aa3478bd.
Report an issue: GitHub.