2727 capture_message ,
2828 capture_exception ,
2929)
30+ from sentry_sdk .consts import DEFAULT_MAX_VALUE_LENGTH
3031from sentry_sdk .integrations .logging import LoggingIntegration
3132from sentry_sdk .serializer import MAX_DATABAG_BREADTH
3233
@@ -250,7 +251,7 @@ def login():
250251def test_flask_large_json_request (sentry_init , capture_events , app ):
251252 sentry_init (integrations = [flask_sentry .FlaskIntegration ()])
252253
253- data = {"foo" : {"bar" : "a" * 2000 }}
254+ data = {"foo" : {"bar" : "a" * ( DEFAULT_MAX_VALUE_LENGTH + 10 ) }}
254255
255256 @app .route ("/" , methods = ["POST" ])
256257 def index ():
@@ -268,9 +269,14 @@ def index():
268269
269270 (event ,) = events
270271 assert event ["_meta" ]["request" ]["data" ]["foo" ]["bar" ] == {
271- "" : {"len" : 2000 , "rem" : [["!limit" , "x" , 1021 , 1024 ]]}
272+ "" : {
273+ "len" : DEFAULT_MAX_VALUE_LENGTH + 10 ,
274+ "rem" : [
275+ ["!limit" , "x" , DEFAULT_MAX_VALUE_LENGTH - 3 , DEFAULT_MAX_VALUE_LENGTH ]
276+ ],
277+ }
272278 }
273- assert len (event ["request" ]["data" ]["foo" ]["bar" ]) == 1024
279+ assert len (event ["request" ]["data" ]["foo" ]["bar" ]) == DEFAULT_MAX_VALUE_LENGTH
274280
275281
276282def test_flask_session_tracking (sentry_init , capture_envelopes , app ):
@@ -338,7 +344,7 @@ def index():
338344def test_flask_medium_formdata_request (sentry_init , capture_events , app ):
339345 sentry_init (integrations = [flask_sentry .FlaskIntegration ()])
340346
341- data = {"foo" : "a" * 2000 }
347+ data = {"foo" : "a" * ( DEFAULT_MAX_VALUE_LENGTH + 10 ) }
342348
343349 @app .route ("/" , methods = ["POST" ])
344350 def index ():
@@ -360,9 +366,14 @@ def index():
360366
361367 (event ,) = events
362368 assert event ["_meta" ]["request" ]["data" ]["foo" ] == {
363- "" : {"len" : 2000 , "rem" : [["!limit" , "x" , 1021 , 1024 ]]}
369+ "" : {
370+ "len" : DEFAULT_MAX_VALUE_LENGTH + 10 ,
371+ "rem" : [
372+ ["!limit" , "x" , DEFAULT_MAX_VALUE_LENGTH - 3 , DEFAULT_MAX_VALUE_LENGTH ]
373+ ],
374+ }
364375 }
365- assert len (event ["request" ]["data" ]["foo" ]) == 1024
376+ assert len (event ["request" ]["data" ]["foo" ]) == DEFAULT_MAX_VALUE_LENGTH
366377
367378
368379def test_flask_formdata_request_appear_transaction_body (
@@ -441,7 +452,10 @@ def test_flask_files_and_form(sentry_init, capture_events, app):
441452 integrations = [flask_sentry .FlaskIntegration ()], max_request_body_size = "always"
442453 )
443454
444- data = {"foo" : "a" * 2000 , "file" : (BytesIO (b"hello" ), "hello.txt" )}
455+ data = {
456+ "foo" : "a" * (DEFAULT_MAX_VALUE_LENGTH + 10 ),
457+ "file" : (BytesIO (b"hello" ), "hello.txt" ),
458+ }
445459
446460 @app .route ("/" , methods = ["POST" ])
447461 def index ():
@@ -463,9 +477,14 @@ def index():
463477
464478 (event ,) = events
465479 assert event ["_meta" ]["request" ]["data" ]["foo" ] == {
466- "" : {"len" : 2000 , "rem" : [["!limit" , "x" , 1021 , 1024 ]]}
480+ "" : {
481+ "len" : DEFAULT_MAX_VALUE_LENGTH + 10 ,
482+ "rem" : [
483+ ["!limit" , "x" , DEFAULT_MAX_VALUE_LENGTH - 3 , DEFAULT_MAX_VALUE_LENGTH ]
484+ ],
485+ }
467486 }
468- assert len (event ["request" ]["data" ]["foo" ]) == 1024
487+ assert len (event ["request" ]["data" ]["foo" ]) == DEFAULT_MAX_VALUE_LENGTH
469488
470489 assert event ["_meta" ]["request" ]["data" ]["file" ] == {"" : {"rem" : [["!raw" , "x" ]]}}
471490 assert not event ["request" ]["data" ]["file" ]
0 commit comments