{"record":{"id":"66d99011642a399f","repo":"apache/iceberg","slug":"cannot-apply-unknown-wap-id-s","errorCode":null,"errorMessage":"Cannot apply unknown WAP ID '%s'","messagePattern":"Cannot apply unknown WAP ID '(.+?)'","errorType":"exception","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/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.0/spark/src/main/java/org/apache/iceberg/spark/procedures/PublishChangesProcedure.java#L94-L130","documentation":"PublishChangesProcedure looks up a staged snapshot whose summary 'wap.id' equals the supplied wap_id argument. If no snapshot in the table's history matches, it throws this ValidationException: there is nothing staged to publish under that ID. Publishing is skipped and the table is left unchanged.","triggerScenarios":"CALL publish_changes(table => 'db.t', wap_id => 'X') where no snapshot summary contains wap.id=X — the staged write never happened, the snapshot was already published or expired, or the passed ID doesn't match the writer's ID.","commonSituations":"Calling publish before the staging write committed; typos or case mismatch in the wap_id string; the staged snapshot was removed by expire_snapshots; running publish against a table that was written without WAP mode enabled (spark.wap.id unset).","solutions":["Check staged snapshots exist: SELECT * FROM db.t.snapshots and inspect summary['wap.id'].","Confirm the writer ran with spark.wap.id set before re-running publish_changes with the exact same value.","Pass the exact wap.id string used at write time (watch whitespace/case).","If already published, no action needed — the error is expected for a second publish attempt."],"exampleFix":"-- before\nCALL iceberg.system.publish_changes(table => 'db.t', wap_id => '1234');\n-- after (use id verified in snapshots metadata)\nSELECT snapshot_id, summary['wap.id'] FROM db.t.snapshots;\nCALL iceberg.system.publish_changes(table => 'db.t', wap_id => '1234-abcd');","handlingStrategy":"validation","validationCode":"assert table.snapshots().stream().anyMatch(s -> wapId.equals(s.summary().get(\"wap.id\"))) : \"no staged snapshot for wap.id\";","typeGuard":null,"tryCatchPattern":"try { publishChanges(table, wapId); } catch (ValidationException e) { /* unknown WAP ID: verify staged write committed */ }","preventionTips":["Confirm the staged write committed before publishing.","Copy the wap.id exactly as written at write time.","Check the snapshots metadata table for the ID first."],"tags":["spark","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"}