← baseline_full

fastapi_14616

failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · fastapi/fastapi

Task input

🐛 Fix using `Json[list[str]]` type (issue #10997)

Fixes Form() not working with Pydantic `Json[T]` types when T is a sequence type (list, set, tuple).

Closes #10997

When using `Form()` with `Json[list[str]]`, FastAPI incorrectly treated it as a sequence field and used `getlist()`, wrapping the JSON string in a list. This caused Pydantic to fail parsing with:
```
TypeError: JSON input should be string, bytes or bytearray
```

**Before fix:**
```python
# Client sends
data = {"items": '["abc", "def"]'}  # JSON string

# FastAPI incorrectly does
value = values.getlist("items")  # ['["abc", "def"]']  ❌
```

**After fix:**
```python
# FastAPI correctly does
value = values.get("items")  # '["abc", "def"]'  ✅
```

This fix enables legitimate use cases like file uploads with JSON metadata:

```python
@app.post("/upload")
def upload(
    file: UploadFile,
    tags: Annotated[Json[list[str]], Form()]
):
    return {"file": file.filename, "tags": tags}
```

Pydantic v1 support for `Json[T]` with `Form()` is not included in this PR because `metadata` attribute does not exist in Pydantic v1's `FieldInfo`.

## Related
- Issue #10997

Tool calls (0)

#ToolArgumentsResult
No trace captured.