Skip to content

any converter should validate value to url_for #2388

@vnznznz

Description

@vnznznz

Expectation:
When using url_for for an endpoint with an <any(foo, bar):arg> argument in its route, it will raise an error for arguments that are not part of the any statement.

Actual result:
It returns an invalid URL

Example:

from flask import Flask, url_for, redirect

app = Flask(__name__)

@app.route("/any/<any(foo, bar):part>")
def url_with_any(part):
    return part

@app.route("/")
def index():
    return redirect(url_for("url_with_any", part="doesnotexist")) # this will 404

Environment:

  • Python version: Python 3.10.4
  • Flask version: Flask 2.1.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions