Commit 18847b1
committed
fix: use fresh upload_url after asset deletion to prevent 422 errors
**Problem:**
After deleting an existing asset with different size, the upload fails
with 422 Unprocessable Entity because we were using the upload_url from
the initial release object instead of the refreshed one.
**Root Cause:**
- upload_url was captured at the beginning from the initial release object
- After deleting an asset, GitHub may invalidate or update the upload_url
- The old upload_url was being used, causing 422 errors
**Solution:**
1. Remove early upload_url extraction
2. Always use fresh_release for upload_url
3. After asset deletion, refresh release data again
4. Extract upload_url from fresh_release just before upload
**Flow:**
1. Refresh release → get current assets list
2. If asset exists with different size → delete it
3. Refresh again after deletion → get updated upload_url
4. Extract upload_url from fresh data → upload
**Testing:**
This should fix the nats_exporter DEB upload that was failing with:
- Local size: 4106706 bytes
- Remote size: 4106680 bytes (26 bytes difference)
- After deletion → 422 error on re-upload1 parent fbebdf5 commit 18847b1
1 file changed
+13
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 145 | | |
151 | 146 | | |
152 | 147 | | |
153 | 148 | | |
154 | 149 | | |
155 | 150 | | |
156 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
193 | 200 | | |
194 | 201 | | |
195 | 202 | | |
| |||
0 commit comments