Skip to content

Commit feca650

Browse files
authored
refactor(apigateway): remove POWERTOOLS_EVENT_HANDLER_DEBUG env var (#1620)
1 parent bf0ae43 commit feca650

File tree

4 files changed

+12
-35
lines changed

4 files changed

+12
-35
lines changed

Diff for: aws_lambda_powertools/event_handler/api_gateway.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import base64
22
import json
33
import logging
4-
import os
54
import re
65
import traceback
76
import warnings
@@ -26,9 +25,8 @@
2625

2726
from aws_lambda_powertools.event_handler import content_types
2827
from aws_lambda_powertools.event_handler.exceptions import NotFoundError, ServiceError
29-
from aws_lambda_powertools.shared import constants
3028
from aws_lambda_powertools.shared.cookies import Cookie
31-
from aws_lambda_powertools.shared.functions import powertools_dev_is_set, strtobool
29+
from aws_lambda_powertools.shared.functions import powertools_dev_is_set
3230
from aws_lambda_powertools.shared.json_encoder import Encoder
3331
from aws_lambda_powertools.utilities.data_classes import (
3432
ALBEvent,
@@ -459,7 +457,7 @@ def __init__(
459457
cors: CORSConfig
460458
Optionally configure and enabled CORS. Not each route will need to have to cors=True
461459
debug: Optional[bool]
462-
Enables debug mode, by default False. Can be also be enabled by "POWERTOOLS_EVENT_HANDLER_DEBUG"
460+
Enables debug mode, by default False. Can be also be enabled by "POWERTOOLS_DEV"
463461
environment variable
464462
serializer : Callable, optional
465463
function to serialize `obj` to a JSON formatted `str`, by default json.dumps
@@ -552,14 +550,6 @@ def _has_debug(debug: Optional[bool] = None) -> bool:
552550
if debug is not None:
553551
return debug
554552

555-
# Maintenance: deprecate EVENT_HANDLER_DEBUG later in V2.
556-
env_debug = os.getenv(constants.EVENT_HANDLER_DEBUG_ENV)
557-
if env_debug is not None:
558-
warnings.warn(
559-
"POWERTOOLS_EVENT_HANDLER_DEBUG is set and will be deprecated in V2. Please use POWERTOOLS_DEV instead."
560-
)
561-
return strtobool(env_debug) or powertools_dev_is_set()
562-
563553
return powertools_dev_is_set()
564554

565555
@staticmethod

Diff for: aws_lambda_powertools/shared/constants.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
METRICS_NAMESPACE_ENV: str = "POWERTOOLS_METRICS_NAMESPACE"
1212

13-
EVENT_HANDLER_DEBUG_ENV: str = "POWERTOOLS_EVENT_HANDLER_DEBUG"
14-
1513
SERVICE_NAME_ENV: str = "POWERTOOLS_SERVICE_NAME"
1614
XRAY_TRACE_ID_ENV: str = "_X_AMZN_TRACE_ID"
1715
LAMBDA_TASK_ROOT_ENV: str = "LAMBDA_TASK_ROOT"

Diff for: docs/index.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
5454

5555
=== "x86_64"
5656

57-
| Region | Layer ARN |
58-
| ---------------- | -------------------------------------------------------------------------------------------------------- |
57+
| Region | Layer ARN |
58+
| ---------------- | --------------------------------------------------------------------------------------------------------- |
5959
| `af-south-1` | [arn:aws:lambda:af-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: |
6060
| `ap-east-1` | [arn:aws:lambda:ap-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: |
6161
| `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPythonV2:1](#){: .copyMe}:clipboard: |
@@ -81,8 +81,8 @@ You can include Lambda Powertools Lambda Layer using [AWS Lambda Console](https:
8181

8282
=== "arm64"
8383

84-
| Region | Layer ARN |
85-
| ---------------- | -------------------------------------------------------------------------------------------------------- |
84+
| Region | Layer ARN |
85+
| ---------------- | --------------------------------------------------------------------------------------------------------------- |
8686
| `af-south-1` | [arn:aws:lambda:af-south-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: |
8787
| `ap-east-1` | [arn:aws:lambda:ap-east-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: |
8888
| `ap-northeast-1` | [arn:aws:lambda:ap-northeast-1:017000801446:layer:AWSLambdaPowertoolsPythonV2-Arm64:1](#){: .copyMe}:clipboard: |
@@ -377,7 +377,7 @@ Serverless Application Repository (SAR) App deploys a CloudFormation stack with
377377
Despite having more steps compared to the [public Layer ARN](#lambda-layer) option, the benefit is that you can specify a semantic version you want to use.
378378

379379
| App | ARN | Description |
380-
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
380+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
381381
| [aws-lambda-powertools-python-layer-v2](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-v2) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2](#){: .copyMe}:clipboard: | Contains all extra dependencies (e.g: pydantic). |
382382
| [aws-lambda-powertools-python-layer-v2-arm64](https://serverlessrepo.aws.amazon.com/applications/eu-west-1/057560766410/aws-lambda-powertools-python-layer-v2-arm64) | [arn:aws:serverlessrepo:eu-west-1:057560766410:applications/aws-lambda-powertools-python-layer-v2-arm64](#){: .copyMe}:clipboard: | Contains all extra dependencies (e.g: pydantic). For arm64 functions. |
383383

@@ -625,7 +625,6 @@ Core utilities such as Tracing, Logging, Metrics, and Event Handler will be avai
625625
| **POWERTOOLS_LOGGER_LOG_EVENT** | Logs incoming event | [Logging](./core/logger) | `false` |
626626
| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logger) | `0` |
627627
| **POWERTOOLS_LOG_DEDUPLICATION_DISABLED** | Disables log deduplication filter protection to use Pytest Live Log feature | [Logging](./core/logger) | `false` |
628-
| **POWERTOOLS_EVENT_HANDLER_DEBUG** | Enables debugging mode for event handler | [Event Handler](./core/event_handler/api_gateway.md#debug-mode) | `false` |
629628
| **POWERTOOLS_DEV** | Increases verbosity across utilities | Multiple; see [POWERTOOLS_DEV effect below](#increasing-verbosity-across-utilities) | `0` |
630629
| **LOG_LEVEL** | Sets logging level | [Logging](./core/logger) | `INFO` |
631630

@@ -638,11 +637,11 @@ Whether you're prototyping locally or against a non-production environment, you
638637

639638
When `POWERTOOLS_DEV` is set to a truthy value (`1`, `true`), it'll have the following effects:
640639

641-
| Utility | Effect |
642-
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
643-
| **Logger** | Increase JSON indentation to 4. This will ease local debugging when running functions locally under emulators or direct calls while not affecting unit tests |
644-
| **Event Handler** | Enable full traceback errors in the response, indent request/responses, and CORS in dev mode (`*`). This will deprecate [`POWERTOOLS_EVENT_HANDLER_DEBUG`](https://awslabs.github.io/aws-lambda-powertools-python/latest/core/event_handler/api_gateway/#debug-mode) in the future. |
645-
| **Tracer** | Future-proof safety to disables tracing operations in non-Lambda environments. This already happens automatically in the Tracer utility. |
640+
| Utility | Effect |
641+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
642+
| **Logger** | Increase JSON indentation to 4. This will ease local debugging when running functions locally under emulators or direct calls while not affecting unit tests |
643+
| **Event Handler** | Enable full traceback errors in the response, indent request/responses, and CORS in dev mode (`*`). |
644+
| **Tracer** | Future-proof safety to disables tracing operations in non-Lambda environments. This already happens automatically in the Tracer utility. |
646645

647646
## Debug mode
648647

Diff for: tests/functional/event_handler/test_api_gateway.py

-10
Original file line numberDiff line numberDiff line change
@@ -793,16 +793,6 @@ def raises_error():
793793
assert e.value.args == ("Foo",)
794794

795795

796-
def test_debug_mode_environment_variable(monkeypatch):
797-
# GIVEN a debug mode environment variable is set
798-
monkeypatch.setenv(constants.EVENT_HANDLER_DEBUG_ENV, "true")
799-
app = ApiGatewayResolver()
800-
801-
# WHEN calling app._debug
802-
# THEN the debug mode is enabled
803-
assert app._debug
804-
805-
806796
def test_powertools_dev_sets_debug_mode(monkeypatch):
807797
# GIVEN a debug mode environment variable is set
808798
monkeypatch.setenv(constants.POWERTOOLS_DEV_ENV, "true")

0 commit comments

Comments
 (0)