Page MenuHomeVyOS Platform

http-api: REST form requests fail with newer Starlette (_get_form signature)
Open, HighPublic

Description

MultipartRequest._get_form() in src/services/api/rest/routers.py overrides a private Starlette method with a fixed signature (*, max_files, max_fields). Newer Starlette releases call it with an extra max_part_size argument from Request.form(), so every REST request sent as multipart/form-data or application/x-www-form-urlencoded (the documented curl -F data=... -F key=... form) fails with TypeError and the client gets HTTP 400 "There was an error parsing the body".

Checked with the current vyos-http-api-tools pins (starlette 0.41.3: works), starlette 0.52.1 (pinned by vyos-http-api-tools T9571: broken) and starlette 1.10.0 (broken). This blocks the dependency update in T9571, which is also needed to pick up the Starlette security fixes released only in 1.x.

Fix: accept **kwargs in _get_form() and pass them to MultiPartParser. Works on all three versions; with Starlette 1.x the form size limits are then also enforced for urlencoded bodies.

Details

Version
rolling
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)