Skip to content

Fix convert_from_dapr_duration silently accepting an empty string - #1221

Open
magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:fix/empty-duration-string-silently-parses-to-zero
Open

magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:fix/empty-duration-string-silently-parses-to-zero

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

Description

convert_from_dapr_duration's validity check was not matched or matched.lastindex == 0, but re.Match.lastindex is None, never 0, when no group matched. So an empty or otherwise ungrouped duration string silently parsed to timedelta(0) instead of raising. Fixed by checking matched.lastindex is None.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: N/A, self-discovered while reviewing this file, no existing issue filed.

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested review from a team as code owners September 18, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant