Skip to content

fix: return stable error detail for out-of-range datetimes in str_to_interval - #991

Merged
vincentsarago merged 3 commits into
stac-utils:mainfrom
mohanedmoh:fix-str-to-interval-error-detail
Oct 9, 2026
Merged

vincentsarago merged 3 commits into
stac-utils:mainfrom
mohanedmoh:fix-str-to-interval-error-detail

Conversation

@mohanedmoh

Copy link
Copy Markdown
Contributor

Related Issue(s):

Description:

str_to_interval returned str(e) as the 400 detail for out-of-range datetimes. That text comes from iso8601.ParseError, which wraps CPython's own datetime error, so it differs between Python versions (e.g. month must be in 1..12 on 3.13 vs month must be in 1..12, not 13 on 3.14).

rfc3339_str_to_datetime now converts iso8601.ParseError into ValueError("Invalid RFC3339 datetime."), as its docstring already states. The other fixed messages in str_to_interval are unchanged. Added one parametrized test asserting the exact detail.

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

…interval

iso8601.ParseError forwards the Python-version-dependent datetime error message. Raise a fixed ValueError instead so the 400 detail is the same on every Python version.
@mohanedmoh
mohanedmoh force-pushed the fix-str-to-interval-error-detail branch from 0dc3927 to be7ebec Compare October 7, 2026 08:18
Comment thread stac_fastapi/types/stac_fastapi/types/rfc3339.py Outdated

@jonhealy1 jonhealy1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohanedmoh Thank you

@vincentsarago
vincentsarago merged commit f714efb into stac-utils:main Oct 9, 2026
6 checks passed
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.

str_to_interval returns Python-version-dependent error details

3 participants