Skip to content
Discussion options

You must be logged in to vote

This reproduces on Python 3.13.18 with DRF 3.18.3 and Django 6.1.3 (python:3.13-slim, no network). Through Django's test Client with DEBUG=False, a malformed body gets a 400 and a 200,000-level array gets a 500, with the RecursionError coming out of json.load in JSONParser.parse. The form-data case raises the same error out of is_valid() from JSONField.to_internal_value.

Until a fix is decided, a project can close both off with two small subclasses that answer the deep document the way DRF answers malformed JSON.

# myproject/parsers.py
from rest_framework import serializers
from rest_framework.exceptions import ParseError
from rest_framework.parsers import JSONParser


class SafeJSONParser(…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@auvipy
Comment options

@kasparovabi
Comment options

Answer selected by auvipy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants