apache/iceberg · error · IllegalArgumentException

String.format("Invalid sort direction: ", directionAsString)

Error message

String.format("Invalid sort direction: %s", directionAsString)

What it means

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.

Solutions

  1. Normalize the input to 'ASC' or 'DESC' before parsing (case-insensitive matching is already applied)
  2. Reject or sanitize the source of the direction string in the caller
  3. Check for null separately — a null input produces a distinct error
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at api/src/main/java/org/apache/iceberg/SortDirection.java:33 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/db1e3e037c4608f6. Report an issue: GitHub.

Appendix: source

Thrown at api/src/main/java/org/apache/iceberg/SortDirection.java:33

 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.iceberg;

import java.util.Locale;
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;

public enum SortDirection {
  ASC,
  DESC;

  public static SortDirection fromString(String directionAsString) {
    Preconditions.checkArgument(null != directionAsString, "Invalid sort direction: null");
    try {
      return SortDirection.valueOf(directionAsString.toUpperCase(Locale.ROOT));
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException(
          String.format("Invalid sort direction: %s", directionAsString), e);
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)