Bug: SCHEDULE_BETWEEN_DAYS_OF_WEEK stops matching when LC_TIME is not English

已關閉
#8,706 3 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

@anishmehta24 已經在處理了。

開始於 2026年10月30日。

  • #8707 來自 @anishmehta24 —— 已合併

評估

這個 Issue 還沒有評估資料。

描述

bug feature_flags

Expected Behaviour

A SCHEDULE_BETWEEN_DAYS_OF_WEEK rule with "DAYS": ["FRIDAY"] matches on Fridays whatever locale the function runs with.

Current Behaviour

compare_days_of_week gets the current day with strftime("%A").upper(), which names the day in the process's LC_TIME locale. If the function calls locale.setlocale(locale.LC_TIME, ...) (or LC_ALL) for a non-English locale, the day comes back as FREITAG, VENDREDI, etc., never equals the English names the schema requires, and every day-of-week rule silently stops matching.

Code snippet

import locale
from aws_lambda_powertools.utilities.feature_flags.comparators import compare_days_of_week

cond = {"DAYS": ["FRIDAY"], "TIMEZONE": "UTC"}  # run on a Friday
compare_days_of_week(None, cond)  # True

locale.setlocale(locale.LC_TIME, "de_DE.UTF-8")
compare_days_of_week(None, cond)  # False, the current day is "FREITAG"

Steps to Reproduce

  1. Configure a feature flag rule with SCHEDULE_BETWEEN_DAYS_OF_WEEK and today's day in DAYS.
  2. Set a non-English LC_TIME in the function.
  3. Evaluate the flag: the rule no longer matches.

Possible Solution

Look the day up from datetime.weekday() (Monday is 0) instead of formatting its name, so the result does not depend on the locale. I can open a PR.

Powertools for AWS Lambda (Python) version

latest (develop, 3.38.0)

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

No response

主要語言
Python
星號
3.3k
分支
511
平均合併
3 天 13 小時
30 天內合併 PR
110

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aws-powertools/powertools-lambda-python 的其他 Issue

查看 aws-powertools/powertools-lambda-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。