{"record":{"id":"6e0a0108afc8df49","repo":"larksuite/cli","slug":"metadata-service-is-required","errorCode":null,"errorMessage":"Metadata.Service is required","messagePattern":"Metadata\\.Service is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"shortcuts/common/typed_compiler.go","lineNumber":91,"sourceCode":"\t\tfor i := range authorization.ConditionalScopes {\n\t\t\tconditional := &authorization.ConditionalScopes[i]\n\t\t\tconditional.Scopes = append([]string(nil), conditional.Scopes...)\n\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) == \"\" {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compiler.go#L73-L109","documentation":"Every typed command must declare Metadata.Service, the service/domain segment used to route and namespace the command. validateCommandMetadata rejects an empty (after trimming whitespace) Service value at compile time. The service is part of the public command identity and help/schema surface.","triggerScenarios":"CompileCommandDefinition with typedCommandMetadata{Service: \"\"} — an unset Service field or a value consisting only of whitespace.","commonSituations":"Copying a metadata struct and deleting the Service line; constructing metadata programmatically where the service constant failed to resolve; defining a cross-domain utility command and assuming Service is optional.","solutions":["Set Metadata.Service to the owning service/domain segment, e.g. Service: \"im\" or \"docx\".","If the value is computed, check why it resolves to empty at definition time.","Trim nothing yourself — the validator trims for the emptiness check, but the raw value must equal its trimmed form (see the sibling segment error)."],"exampleFix":"// before\nMetadata: common.Metadata{Command: \"+send\", Description: \"Send a message\"}\n// after\nMetadata: common.Metadata{Service: \"im\", Command: \"+send\", Description: \"Send a message\"}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(string(md.Service)) == \"\" {\n  return fmt.Errorf(\"Metadata.Service must be set\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set Service from a named constant per domain package so it cannot be empty.","Never construct Metadata literals with the Service field omitted.","List required metadata fields in the team checklist for new typed commands."],"tags":["metadata","missing-required-field","compile-time"],"backgroundTag":"missing-required-argument","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"}