{"record":{"id":"cfba1c6d9a8b7097","repo":"warpdotdev/warp","slug":"sort-by-and-sort-order-are-not-supported-with","errorCode":null,"errorMessage":"--sort-by and --sort-order are not supported with JSON output","messagePattern":"--sort-by and --sort-order are not supported with JSON output","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/src/ai/agent_sdk/agent_management.rs","lineNumber":345,"sourceCode":"fn request_is_empty(request: &UpdateAgentRequest) -> bool {\n    request.name.is_none()\n        && request.description.is_none()\n        && request.prompt.is_none()\n        && request.secrets.is_none()\n        && request.skills.is_none()\n        && request.base_model.is_none()\n        && request.environment_id.is_none()\n}\n\nfn ensure_json_sort_is_not_requested(\n    output_format: OutputFormat,\n    json_output: &JsonOutput,\n    args: &AgentListArgs,\n) -> anyhow::Result<()> {\n    if (matches!(output_format, OutputFormat::Json) || json_output.force_json_output())\n        && (args.sort_by.is_some() || args.sort_order.is_some())\n    {\n        return Err(anyhow!(\n            \"--sort-by and --sort-order are not supported with JSON output\"\n        ));\n    }\n\n    Ok(())\n}\n\nfn sort_agents(\n    agents: &mut [AgentResponse],\n    sort_by: Option<AgentSortByArg>,\n    sort_order: Option<SortOrderArg>,\n) {\n    let sort_by = sort_by.unwrap_or(AgentSortByArg::Name);\n    let default_order = match sort_by {\n        AgentSortByArg::Name => SortOrderArg::Asc,\n        AgentSortByArg::CreatedAt => SortOrderArg::Desc,\n    };\n    let sort_order = sort_order.unwrap_or(default_order);","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/agent_management.rs#L327-L363","documentation":"ensure_json_sort_is_not_requested (app/src/ai/agent_sdk/agent_management.rs:335-347) rejects combining JSON output (--output-format json or forced JSON) with --sort-by or --sort-order, because the JSON path returns the server ordering verbatim while sorting is a client-side rendering concern for the non-JSON table. The check runs before any request is made.","triggerScenarios":"Running agents list with --output-format json together with --sort-by and/or --sort-order.","commonSituations":"Scripts that always request sorted JSON; users switching an existing sorted invocation to JSON without dropping the sort flags.","solutions":["Drop the sort flags and sort the JSON client-side, e.g. pipe through jq 'sort_by(.name)'","Keep --sort-by/--sort-order and use the default (non-JSON) output where sorting is applied"],"exampleFix":"# before\nagents list --output-format json --sort-by name\n# after\nagents list --output-format json | jq 'sort_by(.name)'","handlingStrategy":"validation","validationCode":"if (matches!(output_format, OutputFormat::Json) || json_output.force_json_output())\n    && (args.sort_by.is_some() || args.sort_order.is_some())\n{\n    // strip the sort flags (sort client-side after parsing the JSON) or switch to non-JSON output\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sort JSON output in the consuming script (jq sort_by) rather than via CLI flags","Reserve --sort-by/--sort-order for human-facing table output"],"tags":["cli","agents","json","sorting"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}