From b35dd4f9922538bfd5d505e59c3e4e0c03290515 Mon Sep 17 00:00:00 2001 From: Sophie Date: Tue, 30 Dec 2025 11:15:18 +0100 Subject: [PATCH] fix: Add robust error handling to bashio download process Based on feedback from PR #2319 code review: critical network operations need explicit error handling and validation. Added safeguards: - curl -f flag: Fail on HTTP errors (429, 404, 500, etc) - test -s check: Verify downloaded file is not empty - tar extraction error check: Fail if tar extraction fails - lib directory validation: Confirm bashio/lib exists after extraction - Explicit error messages: Clear diagnostics if any step fails This prevents silent failures where downloads could fail but build continues with broken/missing bashio installation. Prevents: Users pulling images with non-functional bashio Impact: Build will fail explicitly with clear error messages if download/extraction fails --- portainer_agent/Dockerfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/portainer_agent/Dockerfile b/portainer_agent/Dockerfile index 934b1dd62..a94d610b5 100644 --- a/portainer_agent/Dockerfile +++ b/portainer_agent/Dockerfile @@ -8,10 +8,15 @@ FROM $BUILD_FROM # Step 1: Replace bashio v0.17.5 with main branch for improved API error handling RUN rm -rf /usr/lib/bashio /usr/bin/bashio && \ - curl -J -L -o /tmp/bashio.tar.gz \ + curl -f -J -L -o /tmp/bashio.tar.gz \ "https://github.com/hassio-addons/bashio/archive/main.tar.gz" && \ + test -f /tmp/bashio.tar.gz && test -s /tmp/bashio.tar.gz || \ + (echo "ERROR: bashio download failed or file is empty" && exit 1) && \ mkdir /tmp/bashio && \ - tar -xzf /tmp/bashio.tar.gz --strip 1 -C /tmp/bashio && \ + tar -xzf /tmp/bashio.tar.gz --strip 1 -C /tmp/bashio || \ + (echo "ERROR: bashio tar extraction failed" && exit 1) && \ + test -d /tmp/bashio/lib || \ + (echo "ERROR: bashio lib directory not found after extraction" && exit 1) && \ mv /tmp/bashio/lib /usr/lib/bashio && \ ln -s /usr/lib/bashio/bashio /usr/bin/bashio && \ rm -rf /tmp/bashio /tmp/bashio.tar.gz