Skip to content

fix(feature_flags): warn on comparator evaluation errors - #8470

Open
Shubham-Padkonde wants to merge 1 commit into
aws-powertools:developfrom
Shubham-Padkonde:fix/feature-flag-comparator-warnings
Open

Shubham-Padkonde wants to merge 1 commit into
aws-powertools:developfrom
Shubham-Padkonde:fix/feature-flag-comparator-warnings

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Issue number: #8425 (warning-only step)

Summary

Changes

Emit a warning when a feature-flag comparator raises while evaluating a present context key. Include the feature, rule, key, action, and exception type, without exposing operand values or exception messages. Pass that diagnostic context through the private comparator helper and document the warning.

User experience

Incompatible operands, such as STARTSWITH on an integer, currently look like ordinary non-matches unless debug logging is enabled. They now produce an actionable warning. Existing non-match results and registered exception handlers are preserved; missing keys and valid non-matches stay quiet.

This implements the first step proposed in the issue. Introducing a new exception remains a separate major-version decision. The tested approach was described in the issue before submission.

Validation:

  • Initial functional regression: 7 failed, 2 passed before the change; 9 passed after. An additional exception-message privacy regression brings the final focused suite to 10 passing cases.
  • Full non-performance suite on Python 3.12/Linux: 2,579 passed, 4 skipped, 10 deselected; coverage 96.69%.
  • All 10 performance checks passed.
  • Repository Ruff checks, mypy (897 source files), security and complexity baselines, and modified-Python pre-commit checks passed.
  • make pr stops at its Docker-based documentation command because Docker/WSL integration is unavailable here. Running markdownlint directly passes the edited page; the full docs check reports the pre-existing MD053 error in unchanged docs/changelog.md:1. The remaining check categories were run separately as listed above. AWS end-to-end and Redis integration tests were not run.

Prepared with OpenAI Codex assistance.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Shubham-Padkonde
Shubham-Padkonde requested a review from a team as a code owner September 16, 2026 22:12
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 16, 2026
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation tests labels Sep 16, 2026
@boring-cyborg

boring-cyborg Bot commented Sep 16, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@powertools-for-aws-oss-automation

Copy link
Copy Markdown

Not all issues are linked correctly.

Please link each issue to the PR either manually or using a closing keyword in the format fixes #<issue-number> format.

If mentioning more than one issue, separate them with commas: i.e. fixes #<issue-number-1>, closes #<issue-number-2>.

@sonarqubecloud

Copy link
Copy Markdown

@Shubham-Padkonde

Copy link
Copy Markdown
Author

This implements only the warning-only first step of #8425; the proposed major-version exception behavior remains open. The related-issue check currently requires a development link or a closing keyword. Could a maintainer link #8425 manually (or advise the preferred tracking issue for this first step)? I have avoided a closing keyword so merging this PR does not inadvertently close the remaining major-version work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant