Skip to content
This repository was archived by the owner on Jul 27, 2026. It is now read-only.

[ISSUE-029] Fix usage analytics date serialization — ISO-8601 datetime#56

Merged
pillip merged 2 commits into
mainfrom
issue/ISSUE-029-usage-analytics-date
Jun 15, 2026
Merged

[ISSUE-029] Fix usage analytics date serialization — ISO-8601 datetime#56
pillip merged 2 commits into
mainfrom
issue/ISSUE-029-usage-analytics-date

Conversation

@pillip

@pillip pillip commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #55

Summary

supertone usage analytics forwarded a plain YYYY-MM-DD to the /v1/usage endpoint, which requires a full ISO-8601 datetime. The resulting server 400 surfaced as a confusing SDK ResponseValidationError.

This adds a private _to_iso_datetime(value, *, end) helper in client.py and applies it to start_time/end_time inside get_usage_analytics only:

  • date-only start -> T00:00:00Z
  • date-only end -> T23:59:59Z
  • a value already containing T -> passed through unchanged

get_voice_usage (different endpoint, accepts plain dates) is untouched. CLI --help text stays YYYY-MM-DD.

Tests

  • Unit: date-only start/end conversion asserted against mocked client.usage.get_usage kwargs; already-T passthrough.
  • CLI: usage analytics exits 0 with mocked SDK.
  • Full suite: 157 passed, 1 skipped. ruff clean. Coverage 81.29% (gate >80%).

Track: quality | Priority: P1

pillip and others added 2 commits June 15, 2026 15:48
The /v1/usage endpoint requires full ISO-8601 datetimes; forwarding a
plain YYYY-MM-DD produced a server 400 surfaced as a confusing SDK
ResponseValidationError. Add a private _to_iso_datetime helper and apply
it to start_time/end_time in get_usage_analytics only (date-only start ->
T00:00:00Z, end -> T23:59:59Z; full datetimes pass through). get_voice_usage
is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Senior review: APPROVE. No Critical/High findings. Two Low items
(lowercase t separator, empty-input validation) intentionally not
gold-plated. uv run pytest: 157 passed, 1 skipped. ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pillip
pillip merged commit f6ed203 into main Jun 15, 2026
6 checks passed
@pillip
pillip deleted the issue/ISSUE-029-usage-analytics-date branch June 15, 2026 06:53
pillip added a commit that referenced this pull request Jun 16, 2026
- src/supertone_cli/__init__.py: bump __version__ to 0.2.1
- CHANGELOG.md: cut [0.2.1] - 2026-06-16
  - Fixed: usage analytics now converts YYYY-MM-DD to ISO-8601
    datetime before calling /v1/usage (ISSUE-029, PR #56)
  - Fixed: voices get falls back to the custom-voice endpoint on a
    preset 404 so cloned voices resolve (ISSUE-030, PR #58)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE-029] Fix usage analytics date serialization — convert YYYY-MM-DD to ISO-8601 datetime

1 participant