{"record":{"id":"db1e3e037c4608f6","repo":"apache/iceberg","slug":"string-format-invalid-sort-direction-s-direct","errorCode":null,"errorMessage":"String.format(\"Invalid sort direction: %s\", directionAsString)","messagePattern":"String\\.format\\(\"Invalid sort direction: (.+?)\", directionAsString\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/SortDirection.java","lineNumber":33,"sourceCode":" * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\npackage org.apache.iceberg;\n\nimport java.util.Locale;\nimport org.apache.iceberg.relocated.com.google.common.base.Preconditions;\n\npublic enum SortDirection {\n  ASC,\n  DESC;\n\n  public static SortDirection fromString(String directionAsString) {\n    Preconditions.checkArgument(null != directionAsString, \"Invalid sort direction: null\");\n    try {\n      return SortDirection.valueOf(directionAsString.toUpperCase(Locale.ROOT));\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Invalid sort direction: %s\", directionAsString), e);\n    }\n  }\n}\n","sourceCodeStart":15,"sourceCodeEnd":38,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/SortDirection.java#L15-L38","documentation":"Parse failure in SortDirection.fromString: the string (after null-checking and uppercasing with Locale.ROOT) does not match ASC or DESC. The %s is the offending input string. It fires when partition/sort metadata or user input carries a direction token outside the two accepted values.","triggerScenarios":"Thrown at api/src/main/java/org/apache/iceberg/SortDirection.java:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Normalize the input to 'ASC' or 'DESC' before parsing (case-insensitive matching is already applied)","Reject or sanitize the source of the direction string in the caller","Check for null separately — a null input produces a distinct error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}