{"record":{"id":"e2937ce11f667d19","repo":"cloudflare/cloudflared","slug":"must-be-one-of-logs-admin-host-details","errorCode":null,"errorMessage":"must be one of: logs, admin, host_details","messagePattern":"must be one of: logs, admin, host_details","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/management/cmd.go","lineNumber":103,"sourceCode":"\t// Output JSON to stdout\n\ttokenResponse := struct {\n\t\tToken string `json:\"token\"`\n\t}{Token: token}\n\n\treturn json.NewEncoder(os.Stdout).Encode(tokenResponse)\n}\n\n// parseResource converts resource string to ManagementResource enum\nfunc parseResource(resource string) (cfapi.ManagementResource, error) {\n\tswitch resource {\n\tcase \"logs\":\n\t\treturn cfapi.Logs, nil\n\tcase \"admin\":\n\t\treturn cfapi.Admin, nil\n\tcase \"host_details\":\n\t\treturn cfapi.HostDetails, nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"must be one of: logs, admin, host_details\")\n\t}\n}\n","sourceCodeStart":85,"sourceCodeEnd":106,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/management/cmd.go#L85-L106","documentation":"parseResource maps a resource string to the cfapi.ManagementResource enum and returns \"must be one of: logs, admin, host_details\" for any unrecognized value. This is the inner error that tokenCommand wraps; it defines the exhaustive set of valid management resources.","triggerScenarios":"Called by tokenCommand (from the --resource flag) with a string other than \"logs\", \"admin\", or \"host_details\".","commonSituations":"Misspelling a resource name, wrong letter case, trailing whitespace, or using a resource removed/renamed in a newer cloudflared version.","solutions":["Pass one of the exact lowercase values: logs, admin, host_details","Trim surrounding whitespace from the value if it comes from a script or env var","Consult the docs for your cloudflared version, as the valid resource set may evolve"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Go: validate before calling parseResource\nfunc isValidResource(s string) bool {\n    switch s { case \"logs\", \"admin\", \"host_details\": return true }\n    return false\n}","typeGuard":null,"tryCatchPattern":"r, err := parseResource(s)\nif err != nil {\n    return fmt.Errorf(\"unsupported management resource %q: %w\", s, err)\n}","preventionTips":["Define the resource strings as constants shared by flag parsing and business logic","Reject unknown values early at CLI/flag-validation time with the allowed set in the message","Add a table-driven test enumerating valid and invalid resource strings"],"tags":["cli","enum","validation","management"],"backgroundTag":"invalid-enum-value","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}