{"record":{"id":"625f4f843e33236c","repo":"apache/iceberg","slug":"string-format-invalid-snapshot-ref-type-s-sna","errorCode":null,"errorMessage":"String.format(\"Invalid snapshot ref type: %s\", snapshotRefType)","messagePattern":"String\\.format\\(\"Invalid snapshot ref type: (.+?)\", snapshotRefType\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/SnapshotRefType.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 SnapshotRefType {\n  BRANCH,\n  TAG;\n\n  public static SnapshotRefType fromString(String snapshotRefType) {\n    Preconditions.checkArgument(null != snapshotRefType, \"Invalid snapshot ref type: null\");\n    try {\n      return SnapshotRefType.valueOf(snapshotRefType.toUpperCase(Locale.ROOT));\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Invalid snapshot ref type: %s\", snapshotRefType), e);\n    }\n  }\n}\n","sourceCodeStart":15,"sourceCodeEnd":38,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/SnapshotRefType.java#L15-L38","documentation":"SnapshotRefType.fromString(String) parses a branch/tag reference type string into the SnapshotRefType enum (BRANCH or TAG). Null input is rejected up front, and any non-null value that is not a valid enum name (case-insensitive) is rethrown as this IllegalArgumentException wrapping the original error.","triggerScenarios":"Passing values like \"branches\", \"tag \", \"snapshot\", or a misspelled \"brnch\" to fromString — typically when parsing snapshot ref names containing an @ delimiter (e.g. \"main@tag\") or REST/catalog ref metadata.","commonSituations":"Typo in SQL like ALTER TABLE ... CREATE TAG/BRANCH handling, REST catalog ref payloads with unexpected type strings, or configuration of ref names where the type suffix was hand-written.","solutions":["Use exactly \"branch\" or \"tag\" (case-insensitive) as the ref type string.","Trim whitespace and check for typos before calling fromString.","Guard with SnapshotRefType.valueOf-style validation or catch IllegalArgumentException and default to BRANCH when the type is absent."],"exampleFix":"// before\nSnapshotRefType type = SnapshotRefType.fromString(\"branches\"); // invalid\n// after\nSnapshotRefType type = SnapshotRefType.fromString(\"branch\");","handlingStrategy":"validation","validationCode":"static boolean isValidRefType(String s) {\n  return \"branch\".equalsIgnoreCase(s) || \"tag\".equalsIgnoreCase(s);\n}","typeGuard":null,"tryCatchPattern":"try {\n  type = SnapshotRefType.fromString(refType);\n} catch (IllegalArgumentException e) {\n  type = SnapshotRefType.BRANCH; // default with logged warning\n}","preventionTips":["Normalize ref type strings (trim + lowercase) before parsing.","Only accept \"branch\" or \"tag\" at configuration boundaries.","When splitting names like \"main@tag\", validate the type suffix before calling fromString."],"tags":["java","iceberg","enum","snapshot-ref","parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}