{"record":{"id":"5d212d03c70378a9","repo":"SonarSource/sonarqube","slug":"cannot-sort-on-field","errorCode":null,"errorMessage":"Cannot sort on field : ","messagePattern":"Cannot sort on field : ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java","lineNumber":70,"sourceCode":"  }\n\n  private static IssueProcessor getIssueProcessor(String sort) {\n    if (IssueQuery.SORT_BY_SEVERITY.equals(sort)) {\n      return new SeveritySortIssueProcessor();\n    }\n    if (IssueQuery.SORT_BY_STATUS.equals(sort)) {\n      return new StatusSortIssueProcessor();\n    }\n    if (IssueQuery.SORT_BY_CREATION_DATE.equals(sort)) {\n      return new CreationDateSortIssueProcessor();\n    }\n    if (IssueQuery.SORT_BY_UPDATE_DATE.equals(sort)) {\n      return new UpdateDateSortIssueProcessor();\n    }\n    if (IssueQuery.SORT_BY_CLOSE_DATE.equals(sort)) {\n      return new CloseDateSortIssueProcessor();\n    }\n    throw new IllegalArgumentException(\"Cannot sort on field : \" + sort);\n  }\n\n  interface IssueProcessor {\n    Function sortFieldFunction();\n\n    Ordering sortFieldOrdering(boolean ascending);\n\n    default List<IssueDto> sort(Collection<IssueDto> issueDtos, boolean ascending) {\n      Ordering<IssueDto> ordering = sortFieldOrdering(ascending).onResultOf(sortFieldFunction());\n      return ordering.immutableSortedCopy(issueDtos);\n    }\n  }\n\n  abstract static class TextSortIssueProcessor implements IssueProcessor {\n    @Override\n    public Function sortFieldFunction() {\n      return (Function<IssueDto, String>) this::sortField;\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssuesFinderSort.java#L52-L88","documentation":"Raised when api/issues/search receives a 'sort' (s) value that IssuesFinderSort cannot map to a known sort processor. Only a fixed set of sort fields is supported and the request value is passed through to the issue index.","triggerScenarios":"Calling GET api/issues/search with s=<unsupported field>, e.g. s=created (instead of CREATION_DATE) or a custom field name; sort values differ from what Elasticsearch indexing supports for issues.","commonSituations":"Guessing sort field names instead of using documented values (FILE_LINE, SEVERITY, UPDATE_DATE, CLOSE_DATE, etc.); copy-pasting sort values from other SonarQube endpoints like rules or components; older servers lacking newer sort fields.","solutions":["Use a supported sort value (e.g. SEVERITY, CREATION_DATE, UPDATE_DATE, FILE_LINE, CLOSE_DATE)","Check the api/issues/search documentation for the exact allowed sort values on your server version","Remove the sort parameter if default ordering is acceptable"],"exampleFix":"// before\ncurl '.../api/issues/search?projectKeys=p&s=created'\n// after\ncurl '.../api/issues/search?projectKeys=p&s=CREATION_DATE'","handlingStrategy":"validation","validationCode":"const ALLOWED_SORTS = ['FILE_LINE','SEVERITY','UPDATE_DATE','CLOSE_DATE','CREATION_DATE'];\nif (sort && !ALLOWED_SORTS.includes(sort)) throw new Error(`unsupported sort: ${sort}`);","typeGuard":null,"tryCatchPattern":"try { await get('/api/issues/search', {s: sort}); } catch (e) { if (e.status === 400 && e.message.startsWith('Cannot sort on field')) { /* fall back to default sort */ } else throw e; }","preventionTips":["Whitelist sort values against your server's docs","Centralize sort constants in shared client code","Test sort params against the target SonarQube version"],"tags":["sonarqube","issues","webapi","sorting"],"backgroundTag":"invalid-argument-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}