{"record":{"id":"121b621fe493e9b7","repo":"apache/iceberg","slug":"ignoring-invalid-metrics-mode","errorCode":null,"errorMessage":"Ignoring invalid metrics mode ({}): {}","messagePattern":"Ignoring invalid metrics mode \\((.+?)\\): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/MetricsConfig.java","lineNumber":358,"sourceCode":"            METRICS_MAX_INFERRED_COLUMN_DEFAULTS_DEFAULT);\n    if (maxInferredDefaultColumns < 0) {\n      LOG.warn(\n          \"Invalid value for {} (negative): {}, falling back to {}\",\n          METRICS_MAX_INFERRED_COLUMN_DEFAULTS,\n          maxInferredDefaultColumns,\n          METRICS_MAX_INFERRED_COLUMN_DEFAULTS_DEFAULT);\n      return METRICS_MAX_INFERRED_COLUMN_DEFAULTS_DEFAULT;\n    } else {\n      return maxInferredDefaultColumns;\n    }\n  }\n\n  private static MetricsMode parseMode(String modeString, MetricsMode fallback, String context) {\n    try {\n      return MetricsModes.fromString(modeString);\n    } catch (IllegalArgumentException err) {\n      // User override was invalid, log the error and use the default\n      LOG.warn(\"Ignoring invalid metrics mode ({}): {}\", context, modeString, err);\n      return fallback;\n    }\n  }\n}\n","sourceCodeStart":340,"sourceCodeEnd":363,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/MetricsConfig.java#L340-L363","documentation":"MetricsConfig.parseMode parses a user-supplied metrics mode string (columns.metrics.<col> or write.metrics.default) via MetricsModes.fromString. If the string is not a valid mode (none/count/truncate(L)/full or malformed), the invalid value is logged with this warning and the fallback/default mode is used instead of failing.","triggerScenarios":"Setting 'write.metadata.metrics.default' or 'write.metadata.metrics.column.<name>' to a misspelled or malformed value such as 'truncat(16)', 'string', or 'NONE ' with unexpected case/whitespace that fails parsing, then writing data.","commonSituations":"Typos in truncate syntax (missing length or parenthesis), unknown mode names, column names with special characters requiring quoting, config copied from other engines.","solutions":["Use one of the valid modes: none, count, truncate(N), full.","Fix truncate syntax, e.g. truncate(16), including a positive length.","Remove the invalid property so the default mode applies.","Quote column names with dots or special characters per property-key rules."],"exampleFix":"// before\nprops.put(\"write.metadata.metrics.column.id\", \"truncat(8)\");\n// after\nprops.put(\"write.metadata.metrics.column.id\", \"truncate(8)\");","handlingStrategy":"validation","validationCode":"java.util.Set<String> valid = Set.of(\"none\", \"count\", \"full\");\nif (!valid.contains(mode) && !mode.matches(\"truncate\\\\(\\\\d+\\\\)\")) throw new IllegalArgumentException(\"invalid metrics mode: \" + mode);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use none/count/truncate(N)/full for metrics mode properties","Test property changes on a dev table before production","Quote column names containing dots in property keys"],"tags":["configuration","metrics","invalid-enum"],"backgroundTag":"invalid-config-value","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"}