{"record":{"id":"5175997aa08bc040","repo":"apache/iceberg","slug":"cannot-convert-metadata-update-to-json-unrecogniz","errorCode":null,"errorMessage":"Cannot convert metadata update to json. Unrecognized action: %s","messagePattern":"Cannot convert metadata update to json\\. Unrecognized action: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/MetadataUpdateParser.java","lineNumber":275,"sourceCode":"        break;\n      case SET_CURRENT_VIEW_VERSION:\n        writeSetCurrentViewVersionId(\n            (MetadataUpdate.SetCurrentViewVersion) metadataUpdate, generator);\n        break;\n      case REMOVE_PARTITION_SPECS:\n        writeRemovePartitionSpecs((MetadataUpdate.RemovePartitionSpecs) metadataUpdate, generator);\n        break;\n      case REMOVE_SCHEMAS:\n        writeRemoveSchemas((MetadataUpdate.RemoveSchemas) metadataUpdate, generator);\n        break;\n      case ADD_ENCRYPTION_KEY:\n        writeAddEncryptionKey((MetadataUpdate.AddEncryptionKey) metadataUpdate, generator);\n        break;\n      case REMOVE_ENCRYPTION_KEY:\n        writeRemoveEncryptionKey((MetadataUpdate.RemoveEncryptionKey) metadataUpdate, generator);\n        break;\n      default:\n        throw new IllegalArgumentException(\n            String.format(\n                \"Cannot convert metadata update to json. Unrecognized action: %s\", updateAction));\n    }\n\n    generator.writeEndObject();\n  }\n\n  /**\n   * Read MetadataUpdate from a JSON string.\n   *\n   * @param json a JSON string of a MetadataUpdate\n   * @return a MetadataUpdate object\n   */\n  public static MetadataUpdate fromJson(String json) {\n    return JsonUtil.parse(json, MetadataUpdateParser::fromJson);\n  }\n\n  public static MetadataUpdate fromJson(JsonNode jsonNode) {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/MetadataUpdateParser.java#L257-L293","documentation":"MetadataUpdateParser.toJson switches on the update's action enum and throws IllegalArgumentException when the action has no writer case. This happens when a new MetadataUpdate type is added without extending the parser, or when serializing an update from a newer Iceberg version whose action the current parser does not recognize.","triggerScenarios":"Calling MetadataUpdateParser.toJson on a MetadataUpdate whose MetadataUpdateType is not handled in the switch (e.g. a custom update or one introduced in a newer library version than the parser code).","commonSituations":"Running an older Iceberg client against metadata produced by a newer server/writer that emits new update actions; patched builds adding new update types without updating MetadataUpdateParser.","solutions":["Upgrade the Iceberg core library so MetadataUpdateParser covers the action being serialized.","Verify no custom MetadataUpdate implementations are being passed to the parser; implement custom serialization if needed.","Check the action value in the failing update and confirm it exists in your library version's MetadataUpdateType enum."],"exampleFix":"// before (older Iceberg that lacks ADD_ENCRYPTION_KEY handling)\nMetadataUpdateParser.toJson(update, generator); // throws for ADD_ENCRYPTION_KEY\n// after (upgrade Iceberg so the switch includes the case)\ncase ADD_ENCRYPTION_KEY:\n  writeAddEncryptionKey((MetadataUpdate.AddEncryptionKey) update, generator);\n  break;","handlingStrategy":"try-catch","validationCode":"// pre-validate: confirm the update's action exists in your version's MetadataUpdateType enum\nMetadataUpdateType action = MetadataUpdateType.valueOf(update.getClass());","typeGuard":null,"tryCatchPattern":"try {\n  MetadataUpdateParser.toJson(update, generator);\n} catch (IllegalArgumentException e) {\n  if (!e.getMessage().contains(\"Unrecognized action\")) throw e;\n  LOG.warn(\"Skipping unsupported metadata update action\", e);\n}","preventionTips":["Keep Iceberg core version in sync across writer, catalog, and clients.","Never pass custom MetadataUpdate implementations to the stock parser.","Add a parser case for any new update type introduced in the same change."],"tags":["json-serialization","unrecognized-action","metadata-update","java"],"backgroundTag":"json-serialization-failed","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"}