mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-09 09:21:03 +01:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user