Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .superset/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,29 @@ step_start_electric() {
docker rm "$ELECTRIC_CONTAINER" &> /dev/null || true
fi

# Start Electric container with auto-assigned port
# Use reserved port from SUPERSET_PORT_BASE if available, otherwise auto-assign
local port_flag
if [ -n "${SUPERSET_PORT_BASE:-}" ]; then
ELECTRIC_PORT=$((SUPERSET_PORT_BASE + 9))
port_flag="-p $ELECTRIC_PORT:3000"
else
port_flag="-p 3000"
fi

if ! docker run -d \
--name "$ELECTRIC_CONTAINER" \
-p 3000 \
$port_flag \
-e DATABASE_URL="$DIRECT_URL" \
-e ELECTRIC_SECRET="$ELECTRIC_SECRET" \
electricsql/electric:latest &> /dev/null; then
error "Failed to start Electric container"
return 1
fi

# Get the auto-assigned port
ELECTRIC_PORT=$(docker port "$ELECTRIC_CONTAINER" 3000 | cut -d: -f2)
# Resolve actual port (needed when auto-assigned)
if [ -z "${ELECTRIC_PORT:-}" ]; then
ELECTRIC_PORT=$(docker port "$ELECTRIC_CONTAINER" 3000 | cut -d: -f2)
fi
Comment on lines +282 to +285
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

docker port output parsing may break with IPv6 or multi-line output.

docker port can return multiple lines (IPv4 + IPv6), e.g.:

0.0.0.0:12345
[::]:12345

cut -d: -f2 on the IPv6 line yields :] instead of the port. The multi-line output could also embed a newline in ELECTRIC_PORT.

Suggested fix: extract port reliably
-    ELECTRIC_PORT=$(docker port "$ELECTRIC_CONTAINER" 3000 | cut -d: -f2)
+    ELECTRIC_PORT=$(docker port "$ELECTRIC_CONTAINER" 3000 | head -1 | awk -F: '{print $NF}')
🤖 Prompt for AI Agents
In @.superset/setup.sh around lines 282 - 285, The docker port parsing can break
on IPv6 or multi-line output; update the ELECTRIC_PORT assignment (where
ELECTRIC_PORT is set from docker port "$ELECTRIC_CONTAINER" 3000) to robustly
handle multi-line and bracketed IPv6 addresses by selecting the last non-empty
line of the output and extracting only the trailing numeric port (strip any
brackets/hosts), e.g. use a pipeline that filters out empty lines, picks the
final line, and applies a regex to capture only the digits at the end of the
line so ELECTRIC_PORT becomes a clean numeric port.


# Wait for Electric to be ready
echo " Waiting for Electric to be ready on port $ELECTRIC_PORT..."
Expand Down