Skip to content

Commit 0f671c3

Browse files
committed
[UNSTABLE] Upgrade Werkzeug, Connexion, Flask.
Signed-off-by: Giacomo Marciani <[email protected]>
1 parent 255e1af commit 0f671c3

File tree

7 files changed

+32
-21
lines changed

7 files changed

+32
-21
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ CHANGELOG
1515
- web_viewer: `2024.0-18131-1`
1616
- Upgrade mysql-community-client to version 8.0.39.
1717
- Remove support for Python 3.7 and 3.8, which are in end of life.
18+
- Upgrade Werkzeug to version 3.1.3.
19+
- Upgrade Connexion to version 3.1.x.
20+
- Upgrade Flask to version 3.1.0.
1821

1922
**BUG FIXES**
2023
- When mounting an external OpenZFS, it is no longer required to set the outbound rules for ports 111, 2049, 20001, 20002, 20003.

THIRD-PARTY-LICENSES.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
------
210210

211211
** clickclick; version 20.10.2 -- https://codeberg.org/hjacobs/python-clickclick
212-
** connexion; version 2.13.1 -- https://github.com/zalando/connexion
212+
** connexion; version 3.1.0 -- https://github.com/zalando/connexion
213213
** python-dateutil; version 2.8.2 -- https://github.com/dateutil/dateutil
214214
** constructs; version 3.4.344 -- https://github.com/aws/constructs
215215
** jsii; version 1.85.0 -- https://github.com/aws/jsii
@@ -675,7 +675,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
675675
Copyright 2007 Pallets
676676
** Flask; version 2.2.5 -- https://palletsprojects.com/p/flask
677677
Copyright 2010 Pallets
678-
** Werkzeug; version 2.3.8 -- https://pypi.org/project/Werkzeug/
678+
** Werkzeug; version 3.1.3 -- https://pypi.org/project/Werkzeug/
679679
Copyright 2007 Pallets
680680

681681
Redistribution and use in source and binary forms, with or without

cli/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ aws-cdk.core~=1.164
1616
aws_cdk.aws-cloudwatch~=1.164
1717
aws_cdk.aws-lambda~=1.164
1818
boto3>=1.16.14
19-
connexion~=2.13.0
20-
flask>=2.2.5,<2.3
19+
connexion[flask]==3.1.0
20+
flask==3.1.0
2121
jinja2~=3.0
2222
jmespath~=0.10
2323
jsii==1.85.0
2424
marshmallow~=3.10
2525
PyYAML>=5.3.1,!=5.4
2626
tabulate>=0.8.8,<=0.8.10
27-
werkzeug~=2.0
27+
werkzeug==3.1.0

cli/setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def readme():
4646
"aws-cdk.aws-ssm~=" + CDK_VERSION,
4747
"aws-cdk.aws-sqs~=" + CDK_VERSION,
4848
"aws-cdk.aws-cloudformation~=" + CDK_VERSION,
49-
"werkzeug~=2.0",
50-
"connexion~=2.13.0",
51-
"flask>=2.2.5,<2.3",
49+
"werkzeug==3.1.0",
50+
"connexion[flask]==3.1.0",
51+
"flask==3.1.0",
5252
"jmespath~=0.10",
5353
"jsii==1.85.0",
5454
]

cli/src/pcluster/api/awslambda/serverless_wsgi.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import json
1818
import os
1919
import sys
20+
from urllib.parse import unquote, unquote_plus, urlencode
2021

2122
from werkzeug.datastructures import Headers, MultiDict, iter_multi_items
2223
from werkzeug.http import HTTP_STATUS_CODES
23-
from werkzeug.urls import url_encode, url_unquote, url_unquote_plus
2424
from werkzeug.wrappers import Response
2525

2626
# List of MIME types that should not be base64 encoded. MIME types within `text/*`
@@ -95,8 +95,8 @@ def encode_query_string(event):
9595
if not params:
9696
params = ""
9797
if is_alb_event(event):
98-
params = MultiDict((url_unquote_plus(k), url_unquote_plus(v)) for k, v in iter_multi_items(params))
99-
return url_encode(params)
98+
params = MultiDict((unquote_plus(k), unquote_plus(v)) for k, v in iter_multi_items(params))
99+
return urlencode(params)
100100

101101

102102
def get_script_name(headers, request_context):
@@ -203,7 +203,7 @@ def handle_payload_v1(app, event, context):
203203
environ = {
204204
"CONTENT_LENGTH": str(len(body)),
205205
"CONTENT_TYPE": headers.get("Content-Type", ""),
206-
"PATH_INFO": url_unquote(path_info),
206+
"PATH_INFO": unquote(path_info),
207207
"QUERY_STRING": encode_query_string(event),
208208
"REMOTE_ADDR": event.get("requestContext", {}).get("identity", {}).get("sourceIp", ""),
209209
"REMOTE_USER": event.get("requestContext", {}).get("authorizer", {}).get("principalId", ""),
@@ -247,7 +247,7 @@ def handle_payload_v2(app, event, context):
247247
environ = {
248248
"CONTENT_LENGTH": str(len(body)),
249249
"CONTENT_TYPE": headers.get("Content-Type", ""),
250-
"PATH_INFO": url_unquote(path_info),
250+
"PATH_INFO": unquote(path_info),
251251
"QUERY_STRING": event.get("rawQueryString", ""),
252252
"REMOTE_ADDR": event.get("requestContext", {}).get("http", {}).get("sourceIp", ""),
253253
"REMOTE_USER": event.get("requestContext", {}).get("authorizer", {}).get("principalId", ""),
@@ -295,8 +295,8 @@ def handle_lambda_integration(app, event, context):
295295
environ = {
296296
"CONTENT_LENGTH": str(len(body)),
297297
"CONTENT_TYPE": headers.get("Content-Type", ""),
298-
"PATH_INFO": url_unquote(path_info),
299-
"QUERY_STRING": url_encode(event.get("query", {})),
298+
"PATH_INFO": unquote(path_info),
299+
"QUERY_STRING": urlencode(event.get("query", {})),
300300
"REMOTE_ADDR": event.get("identity", {}).get("sourceIp", ""),
301301
"REMOTE_USER": event.get("principalId", ""),
302302
"REQUEST_METHOD": event.get("method", ""),

cli/src/pcluster/api/encoder.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
# Generated by OpenAPI Generator (python-flask)
1010

1111
import datetime
12+
import json
1213

1314
import six
14-
from connexion.apps.flask_app import FlaskJSONEncoder
15+
from connexion import jsonifier
16+
from connexion.jsonifier import Jsonifier
1517

1618
from pcluster.api.models.base_model_ import Model
1719
from pcluster.utils import to_iso_timestr
1820

1921

20-
class JSONEncoder(FlaskJSONEncoder):
22+
class JSONEncoder(jsonifier.JSONEncoder):
2123
"""Make the model objects JSON serializable."""
2224

2325
include_nulls = False
@@ -35,4 +37,8 @@ def default(self, obj): # pylint: disable=arguments-renamed
3537
return dikt
3638
elif isinstance(obj, datetime.date):
3739
return to_iso_timestr(obj)
38-
return FlaskJSONEncoder.default(self, obj)
40+
return jsonifier.JSONEncoder.default(self, obj)
41+
42+
@staticmethod
43+
def jsonifier():
44+
return Jsonifier(json_=json, cls=JSONEncoder)

cli/src/pcluster/api/flask_app.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import connexion
1212
from connexion import ProblemException
13-
from connexion.decorators.validation import ParameterValidator
13+
from connexion.validators.parameter import ParameterValidator
1414
from flask import Response, jsonify, request
1515
from werkzeug.exceptions import HTTPException
1616

@@ -74,16 +74,18 @@ def __init__(self, swagger_ui: bool = False, validate_responses=False):
7474
assert_valid_node_js()
7575
options = {"swagger_ui": swagger_ui}
7676

77-
self.app = connexion.FlaskApp(__name__, specification_dir="openapi/", skip_error_handlers=True)
77+
#TODO find a replacement for FlaskApp(skip_error_handlers=True)
78+
self.app = connexion.FlaskApp(__name__, specification_dir="openapi/")
7879
self.flask_app = self.app.app
79-
self.flask_app.json_encoder = encoder.JSONEncoder
80+
# self.flask_app.json_encoder = encoder.JSONEncoder
8081
self.app.add_api(
8182
"openapi.yaml",
8283
arguments={"title": "ParallelCluster"},
8384
pythonic_params=True,
8485
options=options,
8586
validate_responses=validate_responses,
8687
validator_map={"parameter": CustomParameterValidator},
88+
jsonifier=encoder.JSONEncoder.jsonifier()
8789
)
8890
self.app.add_error_handler(HTTPException, self._handle_http_exception)
8991
self.app.add_error_handler(ProblemException, self._handle_problem_exception)

0 commit comments

Comments
 (0)