{"record":{"id":"3cbb23b7da34c544","repo":"apache/iceberg","slug":"failed-to-refresh-as-ref-s-is-no-longer-valid-3cbb23","errorCode":null,"errorMessage":"Failed to refresh as ref '%s' is no longer valid.","messagePattern":"Failed to refresh as ref '(.+?)' is no longer valid\\.","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":500,"severity":"critical","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieViewOperations.java","lineNumber":59,"sourceCode":"  private static final Logger LOG = LoggerFactory.getLogger(NessieViewOperations.class);\n\n  private final NessieIcebergClient client;\n  private final ContentKey key;\n  private final FileIO fileIO;\n  private IcebergView icebergView;\n\n  NessieViewOperations(ContentKey key, NessieIcebergClient client, FileIO fileIO) {\n    this.key = key;\n    this.client = client;\n    this.fileIO = fileIO;\n  }\n\n  @Override\n  public void doRefresh() {\n    try {\n      client.refresh();\n    } catch (NessieNotFoundException e) {\n      throw new UncheckedIOException(\n          String.format(\n              \"Failed to refresh as ref '%s' is no longer valid.\", client.getRef().getName()),\n          e);\n    }\n    String metadataLocation = null;\n    Reference reference = client.getRef().getReference();\n    try {\n      Content content = client.getApi().getContent().key(key).reference(reference).get().get(key);\n      LOG.debug(\"Content '{}' at '{}': {}\", key, reference, content);\n      if (content == null) {\n        if (currentMetadataLocation() != null) {\n          throw new NoSuchViewException(\"View does not exist: %s in %s\", key, reference);\n        }\n      } else {\n        this.icebergView =\n            content\n                .unwrap(IcebergView.class)\n                .orElseThrow(() -> new NessieContentNotFoundException(key, reference.getName()));","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieViewOperations.java#L41-L77","documentation":"NessieViewOperations.doRefresh converts NessieNotFoundException into an UncheckedIOException with this message when the pinned Nessie ref is no longer valid during view metadata refresh. Identical family to the table-side error (errorIndex 2225) but on the view operations path: the view cannot be refreshed because its reference vanished.","triggerScenarios":"Any view operation (load/refresh/commit) after the branch/tag backing the catalog was deleted or expired; stale ref after branch cleanup automation; wrong ref name configured.","commonSituations":"Feature branches deleted by CI while views still loaded on them; ref rename in Nessie not reflected in Spark/Flink catalog config; retention policies pruning active refs.","solutions":["Check the ref exists via the Nessie API and recreate it if removed.","Reload the view/catalog against an existing ref (setRef or correct catalog properties 'ref'/'asset-ref').","Fix ref-name typos in catalog configuration.","Exclude in-use branches from automated deletion/GC."],"exampleFix":"// before\ncatalog.setRef(\"pr-branch\"); // deleted by CI\nView v = catalog.loadView(TableIdentifier.of(\"ns\", \"v\"));\n// after\ncatalog.setRef(refExists(\"pr-branch\") ? \"pr-branch\" : \"main\");\nView v = catalog.loadView(TableIdentifier.of(\"ns\", \"v\"));","handlingStrategy":"retry","validationCode":"nessieApi.ref().refName(refName).get(); // fails fast if ref missing before loading view","typeGuard":null,"tryCatchPattern":"try { view.refresh(); } catch (UncheckedIOException e) { if (e.getCause() instanceof NessieNotFoundException) { catalog.setRef(\"main\"); view = catalog.loadView(id); } else { throw e; } }","preventionTips":["Verify ref existence before long-running view jobs","Keep catalog 'ref' properties current after branch renames","Protect referenced branches from automated deletion"],"tags":["nessie","view","ref-not-found","refresh","branch-deleted"],"backgroundTag":"entity-not-found","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"}