{"record":{"id":"c1129b91664393af","repo":"apache/iceberg","slug":"cannot-apply-unknown-wap-id-s-c1129b","errorCode":null,"errorMessage":"Cannot apply unknown WAP ID '%s'","messagePattern":"Cannot apply unknown WAP ID '(.+?)'","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/procedures/PublishChangesProcedure.java","lineNumber":112,"sourceCode":"\n    return modifyIcebergTable(\n        tableIdent,\n        table -> {\n          Snapshot matchingSnap = null;\n          for (Snapshot snap : table.snapshots()) {\n            if (wapId.equals(WapUtil.stagedWapId(snap))) {\n              if (matchingSnap != null) {\n                throw new ValidationException(\n                    \"Cannot apply non-unique WAP ID. Found multiple snapshots with WAP ID '%s'\",\n                    wapId);\n              } else {\n                matchingSnap = snap;\n              }\n            }\n          }\n\n          if (matchingSnap == null) {\n            throw new ValidationException(\"Cannot apply unknown WAP ID '%s'\", wapId);\n          }\n\n          long wapSnapshotId = matchingSnap.snapshotId();\n          table.manageSnapshots().cherrypick(wapSnapshotId).commit();\n          Snapshot currentSnapshot = table.currentSnapshot();\n          InternalRow outputRow = newInternalRow(wapSnapshotId, currentSnapshot.snapshotId());\n          return asScanIterator(OUTPUT_TYPE, outputRow);\n        });\n  }\n\n  @Override\n  public String name() {\n    return NAME;\n  }\n\n  @Override\n  public String description() {\n    return \"ApplyWapChangesProcedure\";","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/procedures/PublishChangesProcedure.java#L94-L130","documentation":"PublishChangesProcedure looks up a staged snapshot whose write.wap.id matches the given id. ValidationException is thrown when no snapshot in the table's history carries that WAP ID, so there is nothing to publish.","triggerScenarios":"Calling publish_changes with an id that was never written, was already published (WAP ID removed after cherry-pick), or belongs to a different table; also typos or case mismatches in the id string.","commonSituations":"Running publish_changes before the staged write job committed; calling it twice for the same WAP ID (first call consumes it); pointing the procedure at the wrong table; spark.wap.id not set on the writing job so no staged snapshot got an ID.","solutions":["Confirm the staged write ran with spark.wap.id set to the same value, and that the job committed","Inspect table.snapshots (or the snapshots metadata table) to find existing wap IDs: SELECT * FROM cat.db.t.snapshots","Use the correct table identifier in the procedure call","If the snapshot was already published, no action is needed — publish_changes is not idempotent"],"exampleFix":"// before\nspark-submit ... # job without spark.wap.id set\nCALL cat.system.publish_changes(table => 'cat.db.t', id => 'wap-123'); // unknown\n// after\nspark.conf.set(\"spark.wap.id\", \"wap-123\"); // on the writing job, before commit\nCALL cat.system.publish_changes(table => 'cat.db.t', id => 'wap-123');","handlingStrategy":"validation","validationCode":"val found = spark.table(\"cat.db.t.snapshots\").where(\"properties[\\\"write.wap.id\\\"] = wapId\").count()\nif (found == 0) fail(s\"no staged snapshot with wap.id $wapId\")","typeGuard":null,"tryCatchPattern":"try { spark.sql(call) } catch { case e: ValidationException if e.getMessage.contains(\"unknown WAP ID\") => /* verify write job and id */ }","preventionTips":["Set spark.wap.id on the writing job before commit","Check the snapshots metadata table for existing WAP IDs before calling","Remember publish_changes consumes the staged snapshot — don't call twice with the same id"],"tags":["spark","procedures","wap","snapshot-not-found"],"backgroundTag":"record-not-found","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"}