Skip to content

Preserve UTC query instants across API host timezones - #1155

Merged
mmguero merged 1 commit into
cisagov:sylvesterkaczmarek-mergesfrom
sylvesterkaczmarek:fix/api-query-timezone-invariance-20261006
Oct 7, 2026
Merged

mmguero merged 1 commit into
cisagov:sylvesterkaczmarek-mergesfrom
sylvesterkaczmarek:fix/api-query-timezone-invariance-20261006

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Fixes #1152.

Parse epoch strings as timezone-aware UTC values and give dateparser explicit UTC/timezone-aware settings for timezone-free input. Use the same parser for default bounds, so the query range does not depend on the API host's timezone.

Explicit input offsets, existing relative expressions, missing/invalid-input fallback behavior and inclusive millisecond bounds are preserved. This does not add new input formats or change request authorization, filters or aggregation behavior.

Testing

python -m pytest -q api/tests/test_query_timezones.py

25 focused tests passed; 12 fail on unchanged source. Tests exercise UTC, America/New_York and Asia/Tokyo, equivalent epoch/naive/UTC/offset inputs, defaults, relative expressions, real OpenSearch Search serialization and actual Flask GET/POST aggregation requests.

The API imports normally with credential lookup and network transport isolated. Database search and field-mapping responses are fixed local fixtures. Host timezone changes are restored after each test. No listening server, live database, production credentials or full deployment was used.

Tested on macOS with Python 3.12. New-test formatting, scoped syntax/lint checks and git diff --check pass. No dependency, workflow or version changes.

Thanks for taking a look.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@mmguero mmguero self-assigned this Oct 6, 2026
@mmguero mmguero added the api Related to issues dealing with the Malcolm REST API label Oct 6, 2026
@mmguero mmguero added this to Malcolm Oct 6, 2026
@mmguero mmguero added this to the v26.10.0 milestone Oct 6, 2026
@mmguero mmguero moved this to Review in Malcolm Oct 6, 2026
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Focused timezone validation passes 25 tests across UTC, New York and Tokyo, including real query serialization and Flask GET/POST paths with network/database boundaries isolated. Could a maintainer review this when convenient?

@mmguero
mmguero changed the base branch from main to sylvesterkaczmarek-merges October 7, 2026 14:20
@mmguero
mmguero merged commit b10953c into cisagov:sylvesterkaczmarek-merges Oct 7, 2026
@mmguero mmguero moved this from Done to Released in Malcolm Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to issues dealing with the Malcolm REST API

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

API time ranges shift with the host timezone despite documented UTC defaults

2 participants