{"record":{"id":"1ec973972f08682f","repo":"apache/iceberg","slug":"cannot-convert-metadata-update-action-to-json-s","errorCode":null,"errorMessage":"Cannot convert metadata update action to json: %s","messagePattern":"Cannot convert metadata update action to json: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/MetadataUpdateParser.java","lineNumber":354,"sourceCode":"        return readSetProperties(jsonNode);\n      case REMOVE_PROPERTIES:\n        return readRemoveProperties(jsonNode);\n      case SET_LOCATION:\n        return readSetLocation(jsonNode);\n      case ADD_VIEW_VERSION:\n        return readAddViewVersion(jsonNode);\n      case SET_CURRENT_VIEW_VERSION:\n        return readCurrentViewVersionId(jsonNode);\n      case REMOVE_PARTITION_SPECS:\n        return readRemovePartitionSpecs(jsonNode);\n      case REMOVE_SCHEMAS:\n        return readRemoveSchemas(jsonNode);\n      case ADD_ENCRYPTION_KEY:\n        return readAddEncryptionKey(jsonNode);\n      case REMOVE_ENCRYPTION_KEY:\n        return readRemoveEncryptionKey(jsonNode);\n      default:\n        throw new UnsupportedOperationException(\n            String.format(\"Cannot convert metadata update action to json: %s\", action));\n    }\n  }\n\n  private static void writeAssignUUID(MetadataUpdate.AssignUUID update, JsonGenerator gen)\n      throws IOException {\n    gen.writeStringField(UUID, update.uuid());\n  }\n\n  private static void writeUpgradeFormatVersion(\n      MetadataUpdate.UpgradeFormatVersion update, JsonGenerator gen) throws IOException {\n    gen.writeNumberField(FORMAT_VERSION, update.formatVersion());\n  }\n\n  private static void writeAddSchema(MetadataUpdate.AddSchema update, JsonGenerator gen)\n      throws IOException {\n    gen.writeFieldName(SCHEMA);\n    SchemaParser.toJson(update.schema(), gen);","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/MetadataUpdateParser.java#L336-L372","documentation":"MetadataUpdateParser.fromJson switches on the 'action' field read from JSON and throws UnsupportedOperationException when the action string does not match any known MetadataUpdateType. The message text is slightly misleading — it is raised during JSON-to-update conversion, i.e. reading, not writing. It indicates the JSON contains an action this parser version does not know.","triggerScenarios":"Calling MetadataUpdateParser.fromJson with a JSON node whose 'action' value is unknown to the installed Iceberg version, e.g. 'add-encryption-key' parsed by a version that predates encryption-key updates, or a typo/custom action in hand-edited metadata.","commonSituations":"Downgrading Iceberg versions and replaying metadata update logs written by newer versions; cross-version REST catalog interop where the server emits newer update actions than the client understands.","solutions":["Upgrade the Iceberg core library to a version that recognizes the action in the metadata JSON.","Inspect the 'action' field in the failing JSON and confirm it is not a typo or hand-edited value.","If you must consume the log with an old version, filter out updates with unrecognized actions before parsing."],"exampleFix":"// before\nMetadataUpdate update = MetadataUpdateParser.fromJson(node); // throws on unknown action\n// after (upgrade Iceberg so the switch includes the new case)\ncase ADD_ENCRYPTION_KEY:\n  return readAddEncryptionKey(node);","handlingStrategy":"validation","validationCode":"String action = node.get(\"action\").asText();\nSet<String> known = Set.of(\"assign-uuid\",\"upgrade-format-version\",\"add-snapshot\",\"remove-snapshot\",\n    \"set-snapshot-ref\",\"remove-snapshot-ref\",\"set-snapshot-summary\",\"set-properties\",\"remove-properties\",\n    \"set-location\",\"add-view-version\",\"remove-view-version\",\"set-current-view-version\",\n    \"remove-current-view-version\",\"add-schema\",\"remove-schemas\",\"add-encryption-key\",\"remove-encryption-key\");\nif (!known.contains(action)) throw new IllegalStateException(\"Unknown update action: \" + action);","typeGuard":null,"tryCatchPattern":"try {\n  MetadataUpdate update = MetadataUpdateParser.fromJson(node);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Unknown metadata update action, requires newer Iceberg: {}\", node, e);\n}","preventionTips":["Never run an older Iceberg client against metadata logs written by newer versions.","Validate the 'action' field against your version's MetadataUpdateType enum before parsing.","Bump Iceberg version before downgrading metadata writers/consumers."],"tags":["json-deserialization","unrecognized-action","metadata-update","java"],"backgroundTag":"unsupported-enum-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"}