Commit b6e6a95
authored
Fix FAL img2img parameter mappings for image_urls array endpoints (#183)
# Fix FAL img2img parameter mappings for image_urls array endpoints
## Summary
Fixed 422 (Unprocessable Content) errors for 4 FAL img2img endpoints
that were failing during polling. The root cause was parameter schema
mismatches - these endpoints expect `image_urls` (array) but we were
sending `image_url` (string).
**Changes:**
- **Fixed 4 endpoints**: gemini-25-flash-image/edit,
bytedance/seedream/v4/edit, wan-25-preview/image-to-image,
gpt-image-1-mini/edit
- Updated initialInput to use `image_urls: []` instead of `image_url:
""`
- Added `inputMap: { image_url: "image_urls" }` to map our canonical
field names to endpoint-specific names
- **Updated prepareFalInput** in mutations.ts:
- Now applies endpoint's `inputMap` before processing (maps `image_url`
→ `image_urls`)
- Converts string values to arrays when the target key is `image_urls`
- **Fixed ideogram/v3/edit**: Removed `inputAsset` since this endpoint
only supports inpainting (requires `mask_url` parameter, not suitable
for basic img2img)
The issue was that POST requests were being accepted (IN_QUEUE status),
but jobs failed during worker processing when validation discovered
invalid parameter types. The 422 errors during GET polling were symptoms
of job failure, not polling issues.
## Review & Testing Checklist for Human
**Priority**: 🟡 Yellow (Medium Risk - untested API integration changes)
- [ ] **Test the 4 fixed endpoints** with img2img operations (upload
image, add prompt, generate):
- fal-ai/gemini-25-flash-image/edit
- fal-ai/bytedance/seedream/v4/edit
- fal-ai/wan-25-preview/image-to-image
- fal-ai/gpt-image-1-mini/edit
- Verify jobs complete successfully without 422 errors
- [ ] **Test flux-kontext-lora** (was working before) - ensure inputMap
logic doesn't break working endpoints
- [ ] **Verify ideogram/v3/edit** no longer appears in img2img UI
(correctly hidden since it requires mask for inpainting)
- [ ] Check preview deployment and test with real FAL API key
### Test Plan
1. Open the app in preview deployment
2. For each of the 4 fixed endpoints: Upload a test image, enter a
prompt like "make it ice", click generate
3. Watch the console - should see jobs complete without 422 errors
4. Verify the working endpoint (flux-kontext-lora) still works correctly
### Notes
- Changes based on schema analysis from `data/fal_models_schemas.json`
(extracted exact parameter requirements for each endpoint)
- All lint checks passed
- **Risk**: Changes not tested end-to-end with real API calls -
verification needed in preview deployment
**Link to Devin run**:
https://app.devin.ai/sessions/22310748f3b04363b4e1e0d6a2da0e08
**Requested by**: Ilya Timonin (timoncool@gmail.com) / @timoncool2 files changed
Lines changed: 31 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
165 | 171 | | |
166 | | - | |
| 172 | + | |
167 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
168 | 179 | | |
169 | 180 | | |
170 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
294 | 297 | | |
295 | 298 | | |
296 | 299 | | |
| |||
348 | 351 | | |
349 | 352 | | |
350 | 353 | | |
351 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
352 | 358 | | |
353 | 359 | | |
354 | 360 | | |
| |||
406 | 412 | | |
407 | 413 | | |
408 | 414 | | |
409 | | - | |
410 | | - | |
| 415 | + | |
| 416 | + | |
411 | 417 | | |
412 | 418 | | |
413 | 419 | | |
414 | | - | |
415 | 420 | | |
416 | 421 | | |
417 | 422 | | |
| |||
689 | 694 | | |
690 | 695 | | |
691 | 696 | | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
692 | 704 | | |
693 | 705 | | |
694 | 706 | | |
| |||
0 commit comments