Skip to content

Index Errors in old-style Jinja2Templates.TemplateResponse #2906

@Finwood

Description

@Finwood

The parsing logic for the backward-compatible (pre-0.29.0) list of positional arguments uses index 2 twice:

name = args[0]
context = args[1] if len(args) > 1 else kwargs.get("context", {})
status_code = args[2] if len(args) > 2 else kwargs.get("status_code", 200)
headers = args[2] if len(args) > 2 else kwargs.get("headers")
media_type = args[3] if len(args) > 3 else kwargs.get("media_type")
background = args[4] if len(args) > 4 else kwargs.get("background")

headers, media_type and background should be at indices 3, 4 and 5, respectively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions