Skip to content

Bug: POWERTOOLS_PARAMETERS_MAX_AGE set to an empty or non-integer value crashes every parameters call #8747

Open

Description

@AP24110011695

Expected Behaviour

A malformed POWERTOOLS_PARAMETERS_MAX_AGE environment variable should not crash the Parameters utility. An empty or non-integer value is a configuration problem, so per the compatibility policy in ADR 0006 I would expect a PowertoolsUserWarning and a fallback to the documented default (DEFAULT_MAX_AGE_SECS, 5 seconds) — or at minimum a clear configuration error — so that a config typo degrades to the default caching behavior instead of breaking every parameter and secret lookup.

Current Behaviour

POWERTOOLS_PARAMETERS_MAX_AGE is resolved through resolve_max_age() (aws_lambda_powertools/shared/functions.py), which is a raw int(env). An empty string (common config drift: the variable defined but left empty in IaC/templates) or any non-integer value raises ValueError: invalid literal for int() with base 10: ... before any AWS call is made. The exception is raised before the cache lookup and before the provider's _get(), so every entry point is affected — 13 call sites: BaseProvider.get/get_multiple, all SSM providers and high-level functions (get_parameter, get_parameters, get_parameters_by_path, SSMProvider variants), Secrets (get_secret, get_secrets, SecretsProvider.get), and AppConfig (get_app_config, AppConfigProvider.get).

Observed with POWERTOOLS_PARAMETERS_MAX_AGE="" and "abc" (identical failure shape):

SSMProvider().get: ValueError: invalid literal for int() with base 10: ''
get_parameter:    ValueError: invalid literal for int() with base 10: ''
get_secret:       ValueError: invalid literal for int() with base 10: ''

Baseline with the variable unset behaves normally (the SDK call proceeds and fails only on the dummy credentials used in the repro).

This is the same failure class as #8728 (POWERTOOLS_IDEMPOTENCY_DISABLED crashing on non-boolean values, fixed by #8734 by treating unparsable values as the safe default).

Code snippet

import os

# Simulates config drift: variable defined but empty (same with "abc")
os.environ["POWERTOOLS_PARAMETERS_MAX_AGE"] = ""

from aws_lambda_powertools.utilities.parameters import get_parameter

value = get_parameter("/app/config")

Possible Solution

Mirror the #8734 approach in the Parameters utility: resolve POWERTOOLS_PARAMETERS_MAX_AGE through a small helper that treats empty/unparsable values as DEFAULT_MAX_AGE_SECS and emits a PowertoolsUserWarning naming the ignored value (per ADR 0006: warn now, harden later). Recognized integer values — including 0 (no caching) — behave exactly as today. The single helper in shared/functions.py's caller path (or wrapping resolve_max_age at the parameters boundary) covers all 13 call sites at once.

Steps to Reproduce

  1. Set POWERTOOLS_PARAMETERS_MAX_AGE="" (or abc)
  2. Call any Parameters/Secrets/AppConfig entry point, e.g. get_parameter("/app/config")
  3. A raw ValueError: invalid literal for int() with base 10: '' is raised before any AWS call

I ran this against develop (bc3136c) with a stubbed-credentials environment; the exception surfaces identically from SSMProvider().get(), get_parameter() and get_secret(). With the variable unset, the same calls reach the SDK as expected.

Reproduction (was the snippet above executed?)

Yes, I ran it and saw the failure.

Powertools for AWS Lambda (Python) version

latest (develop bc3136c)

AWS Lambda function runtime

3.13

Packaging format used

PyPi

Debugging logs

Not applicable — the failure is independent of logging; no SDK call is reached.

Activity

  1. boring-cyborg commented on Nov 2, 2026

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  2. powertools-for-aws-oss-automation commented on Nov 2, 2026

    @powertools-for-aws-oss-automation

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out our GitHub Discussions: Join the conversation

  3. AP24110011695 commented on Nov 2, 2026

    @AP24110011695
    Author

    I'd like to work on this one. Plan: add a small resolver at the parameters boundary that treats an empty/unparsable POWERTOOLS_PARAMETERS_MAX_AGE as DEFAULT_MAX_AGE_SECS with a PowertoolsUserWarning naming the ignored value (ADR 0006), covering all 13 call sites, with a failing-first regression test next to the existing env-var tests. I verified the repro on develop (bc3136c) as described in the issue. Happy to follow whichever behavior you prefer (warn+default vs. raise a clear config error).

  4. leandrodamascena commented on Nov 2, 2026

    @leandrodamascena
    Contributor

    Thanks @AP24110011695, confirmed on develop with a real parameter: "" and "abc" both raise ValueError from resolve_max_age. Same shape as #8728 on the Idempotency side, so keep the two consistent. It's yours, assigning you now. This goes into 3.41.0.

  5. added this to the 3.41.0 milestone on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomersparametersParameters utility

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions