5050 local data="$3"
5151 local description="$4"
5252
53- echo "Making $description API call..."
53+ echo "=== DEBUG: API Call Details ==="
54+ echo "Description: $description"
55+ echo "URL: $url"
56+ echo "Method: $method"
57+ echo "Data: $data"
58+ echo "==========================="
59+
5460 response=$(curl -s -w "\n%{http_code}" \
5561 --request "$method" "$url" \
5662 --header "Authorization: Bearer ${{ steps.bytebase-login.outputs.token }}" \
@@ -60,10 +66,20 @@ jobs:
6066 status_code=$(echo "$response" | tail -n1)
6167 body=$(echo "$response" | sed '$d')
6268
69+ echo "=== DEBUG: Parsed Response ==="
6370 echo "Status code: $status_code"
71+ echo "Body length: ${#body}"
72+ echo "Body content:"
73+ echo "$body"
74+ echo "==========================="
75+
6476 if [[ $status_code -lt 200 || $status_code -ge 300 ]]; then
65- echo "Failed $description. Status: $status_code"
66- echo "Response: $body"
77+ echo "Error: Failed $description. Status: $status_code"
78+ return 1
79+ fi
80+
81+ if [[ -z "$body" ]]; then
82+ echo "Error: Empty response body"
6783 return 1
6884 fi
6985
7894 while [[ "$DIR_PATH" == export* ]]; do
7995 if [[ -f "$DIR_PATH/manifest.toml" ]]; then
8096 MANIFEST_PATH="$DIR_PATH/manifest.toml"
81- break 2 # Break out of both loops once found
97+ break 2
8298 fi
8399 DIR_PATH=$(dirname "$DIR_PATH")
84100 done
@@ -89,11 +105,38 @@ jobs:
89105 exit 1
90106 fi
91107
92- # Parse manifest.toml once using built-in tomllib
93- PROJECT=$(python3 -c "import tomllib; print(tomllib.load(open('$MANIFEST_PATH', 'rb'))['project'])")
94- INSTANCE=$(python3 -c "import tomllib; print(tomllib.load(open('$MANIFEST_PATH', 'rb'))['instance'])")
95- DATABASE=$(python3 -c "import tomllib; print(tomllib.load(open('$MANIFEST_PATH', 'rb'))['database'])")
96- FORMAT=$(python3 -c "import tomllib; config=tomllib.load(open('$MANIFEST_PATH', 'rb')); print(config.get('format', 'JSON'))")
108+ echo "Found manifest file at: $MANIFEST_PATH"
109+ echo "Manifest contents:"
110+ cat "$MANIFEST_PATH"
111+
112+ # Parse manifest.toml with error handling
113+ read_toml() {
114+ local key="$1"
115+ python3 -c "
116+ import sys
117+ import tomllib
118+ try :
119+ with open('$MANIFEST_PATH', 'rb') as f :
120+ data = tomllib.load(f)
121+ print(data.get('$key', ''))
122+ except Exception as e :
123+ print(f'Error reading $key : {str(e)}', file=sys.stderr)
124+ sys.exit(1)
125+ "
126+ }
127+
128+ # Read each value with error handling
129+ PROJECT=$(read_toml " project") || exit 1
130+ INSTANCE=$(read_toml "instance") || exit 1
131+ DATABASE=$(read_toml "database") || exit 1
132+ FORMAT=$(read_toml "format") || FORMAT="JSON"
133+
134+ echo "=== Parsed Configuration ==="
135+ echo "Project : $PROJECT"
136+ echo "Instance : $INSTANCE"
137+ echo "Database : $DATABASE"
138+ echo "Format : $FORMAT"
139+ echo "==========================="
97140
98141 # Process each SQL file
99142 for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
0 commit comments