@@ -667,15 +667,40 @@ def count_up(label: str, target: int, duration: float = 0.5, steps: int = 12):
667667 terminal_progress ["message" ] = str (output_message )
668668 st .session_state .last_progress = terminal_progress
669669 render_live_plan (terminal_progress )
670- if failed_payload .get ("kind" ) == "blocked" or "release gate" in str (output_message ).lower ():
671- if st .session_state .active_migration_name :
672- try :
673- data = client .download_migration (st .session_state .active_migration_name )
674- st .download_button ("Download gated artifact" , data = data , file_name = f"{ st .session_state .active_migration_name } .zip" , mime = "application/zip" , width = "stretch" , key = "blocked_demo_download" )
675- except ApiError :
676- st .caption ("Download will be available shortly." )
677- else :
678- st .error (f"Migration failed: { output_message } " )
670+ st .error (f"Migration failed: { output_message } " )
671+
672+ # Keep the download affordance visible for every terminal failure.
673+ # A real migrated ZIP is downloadable when packaging succeeded; otherwise
674+ # provide a small failure report so the user always has a retrievable artifact.
675+ if st .session_state .active_migration_name :
676+ try :
677+ data = client .download_migration (st .session_state .active_migration_name )
678+ st .download_button (
679+ "Download available artifact" ,
680+ data = data ,
681+ file_name = f"{ st .session_state .active_migration_name } .zip" ,
682+ mime = "application/zip" ,
683+ width = "stretch" ,
684+ key = "failed_run_artifact_download" ,
685+ )
686+ except ApiError :
687+ failure_report = {
688+ "migration" : st .session_state .active_migration_name ,
689+ "task_id" : st .session_state .active_task_id ,
690+ "status" : state ,
691+ "message" : str (output_message ),
692+ "result" : failed_payload or status .get ("result" ),
693+ "last_progress" : st .session_state .get ("last_progress" ),
694+ }
695+ st .download_button (
696+ "Download failure report" ,
697+ data = json .dumps (failure_report , indent = 2 , default = str ).encode ("utf-8" ),
698+ file_name = f"{ st .session_state .active_migration_name } -failure-report.json" ,
699+ mime = "application/json" ,
700+ width = "stretch" ,
701+ key = "failed_run_report_download" ,
702+ )
703+ st .caption ("No migrated ZIP was created before the failure; the report preserves the run details for review." )
679704
680705 if status .get ("result" ):
681706 with st .expander ("Workflow payload" , expanded = False ):
0 commit comments