Repository navigation
Validate start/end times in the reporting client and CLI - #335
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The awareness check misses valid naive cases, and the new constraint leaves public documentation and examples inaccurate.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Adds timezone validation and inverted-window warnings to reporting requests.
Changes:
- Rejects timezone-naive client inputs.
- Validates CLI timestamps and warns about inverted ranges.
- Adds client validation tests.
| File | Description |
|---|---|
src/frequenz/client/reporting/_client.py |
Validates request timestamps. |
src/frequenz/client/reporting/cli/__main__.py |
Validates CLI timestamps and warns on inverted ranges. |
tests/test_client_reporting.py |
Tests client-side validation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cwasicki
force-pushed
the
times
branch
2 times, most recently
from
October 19, 2026 19:20
45041d9 to
74589be
Compare
llucax
previously approved these changes
Oct 23, 2026
Contributor
Author
|
Updated |
Contributor
Author
|
Rebased |
A naive datetime is ambiguous: the wire encoding assumes UTC while datetime.timestamp() assumes local time, so the same value would denote different instants. Reject it at the public request boundary rather than silently pick one meaning. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
A naive datetime is ambiguous: the wire encoding assumes UTC while datetime.timestamp() assumes local time. Reject it at the argparse boundary so the CLI fails with a clear message instead of a ValueError. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
At the CLI an inverted window is almost always a typo, and failing makes scripts that build bad arguments notice. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
AC_ACTIVE_POWER and AC_REACTIVE_POWER are not members of Metric. The CLI validates --metrics against the enum, so the documented command errored out, and the Python examples referenced attributes that do not exist. Use the actual names AC_POWER_ACTIVE and AC_POWER_REACTIVE. Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
Contributor
Author
|
Rebased again on latest head. |
florian-wagner-frequenz
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Guards the reporting request time range against two easy mistakes: ambiguous naive datetimes and an inverted window.
start_time/end_timein the client. A naive value is ambiguous, the wire encoding reads it as UTC whiledatetime.timestamp()reads it as local time, so the same input would denote different instants. Theclient now raises rather than silently pick one meaning.
--start/--endarguments, so a naive value fails at argument parsing with a clear message instead of surfacing as aValueErrorlater.--endprecedes--start. The inverted window is still a legal, empty range and the request runs, but at the CLI it is almost always a typo, and the warning explains the otherwise silent empty output.