{"record":{"id":"1722152515a5872d","repo":"larksuite/cli","slug":"metadata-service-q-must-be-one-trimmed-command-se","errorCode":null,"errorMessage":"Metadata.Service %q must be one trimmed command segment","messagePattern":"Metadata\\.Service %q must be one trimmed command segment","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compiler.go","lineNumber":94,"sourceCode":"\t\t\tconditional.Params = append([]string(nil), conditional.Params...)\n\t\t\tif conditional.Requirement == \"\" {\n\t\t\t\tconditional.Requirement = typedScopeRequired\n\t\t\t}\n\t\t}\n\t\tidentities[identity] = authorization\n\t}\n\tmetadata.Authorization.Identities = identities\n\tmetadata.Authorization.IdentityOrder = append([]typedIdentity(nil), metadata.Authorization.IdentityOrder...)\n\treturn metadata\n}\n\nfunc validateCommandMetadata(metadata typedCommandMetadata) error {\n\tservice := strings.TrimSpace(string(metadata.Service))\n\tif service == \"\" {\n\t\treturn fmt.Errorf(\"Metadata.Service is required\")\n\t}\n\tif service != string(metadata.Service) || strings.ContainsAny(service, \" \\t\\r\\n/\") {\n\t\treturn fmt.Errorf(\"Metadata.Service %q must be one trimmed command segment\", metadata.Service)\n\t}\n\tcommand := strings.TrimSpace(metadata.Command)\n\tif command == \"\" {\n\t\treturn fmt.Errorf(\"Metadata.Command is required\")\n\t}\n\tif command != metadata.Command || strings.ContainsAny(command, \" \\t\\r\\n/\") {\n\t\treturn fmt.Errorf(\"Metadata.Command %q must be one trimmed command segment\", metadata.Command)\n\t}\n\tif !strings.HasPrefix(command, \"+\") {\n\t\treturn fmt.Errorf(\"Metadata.Command %q must start with '+'\", metadata.Command)\n\t}\n\tif command == \"+\" {\n\t\treturn fmt.Errorf(\"Metadata.Command must contain a name after '+'\")\n\t}\n\tif strings.TrimSpace(metadata.Description) == \"\" {\n\t\treturn fmt.Errorf(\"Metadata.Description is required\")\n\t}\n\tswitch metadata.Risk {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compiler.go#L76-L112","documentation":"Metadata.Service must be exactly one command segment: the raw value must equal its whitespace-trimmed form (no leading/trailing spaces) and must contain no spaces, tabs, carriage returns, newlines, or slashes. Slashes would imply nested paths, which the metadata model does not allow for Service.","triggerScenarios":"CompileCommandDefinition with Service values like \"im \" (trailing space), \" im\", \"instant messaging\", \"docs/wikis\", or any multi-word or path-like string.","commonSituations":"Writing a human-readable label (\"Instant Messaging\") instead of the single segment identifier; copying an API path (\"im/v1/chats\") into Service; trailing whitespace from an editor or string concatenation.","solutions":["Replace Service with a single lowercase segment, e.g. \"im\"; put the readable name in Metadata.Description.","Move any path-like portion into Metadata.Command (which starts with '+') rather than Service.","Trim the value at its source so no leading/trailing whitespace is stored.","If you need a compound name, use a hyphen or dot if permitted by convention — never a slash or space."],"exampleFix":"// before\nMetadata: common.Metadata{Service: \"docs/wikis\", Command: \"+create\"}\n// after\nMetadata: common.Metadata{Service: \"docx\", Command: \"+create\"}","handlingStrategy":"validation","validationCode":"func validServiceSegment(s string) bool {\n  t := strings.TrimSpace(s)\n  return t != \"\" && t == s && !strings.ContainsAny(t, \" \\t\\r\\n/\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a single lowercase identifier (e.g. \"im\", \"docx\") for Service; never prose or API paths.","Store service names as constants so formatting/whitespace cannot creep in.","Keep readable wording in Metadata.Description instead of Service."],"tags":["metadata","validation","naming","compile-time"],"backgroundTag":"invalid-identifier-format","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}