Skip to content

fix: normalize null timestamps in Kraken flat-rate export tariffs#3705

Merged
springfall2008 merged 1 commit intomainfrom
fix/kraken-flat-rate-null-timestamps
Mar 30, 2026
Merged

fix: normalize null timestamps in Kraken flat-rate export tariffs#3705
springfall2008 merged 1 commit intomainfrom
fix/kraken-flat-rate-null-timestamps

Conversation

@mgazza
Copy link
Copy Markdown
Collaborator

@mgazza mgazza commented Mar 30, 2026

Summary

  • Kraken's REST API returns valid_from: null, valid_to: null for flat-rate export tariffs (e.g. fixed E.ON export rates)
  • minute_data() in utils.py expects valid_from to be a parsable ISO timestamp — str2time(None) throws an exception and silently skips the rate
  • This caused metric_octopus_export not set correctly errors for Kraken/E.ON customers with flat-rate export tariffs
  • Added _normalize_rate_timestamps() static method to KrakenAPI that fills null valid_from with a sensible fallback (earliest valid_to across results, or 48h in the past)
  • Added 4 new tests covering: flat-rate both-null case, normal rates passthrough, empty list, and mixed null/real timestamps

Test plan

  • All 28 tests pass (24 existing + 4 new)
  • Pre-commit hooks pass (CSpell, Black, Ruff)
  • Deploy to Eon customer instance and verify export rates populate correctly

🤖 Generated with Claude Code

Kraken's REST API returns valid_from=null and valid_to=null for
flat-rate tariffs (e.g. E-1R-NEXT_EXPORT_EXCLUSIVE_V2-H). Unlike
Octopus which always provides real timestamps, this causes minute_data()
to skip the rate entirely, resulting in "metric_octopus_export not set
correctly" errors for E.ON/EDF customers with fixed export tariffs.

Add _normalize_rate_timestamps() to fill in null valid_from with a
sensible default (48h in the past for pure flat rates, or the earliest
valid_to when mixed with timestamped entries). valid_to=null is already
handled by minute_data() so is left as-is.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mgazza
Copy link
Copy Markdown
Collaborator Author

mgazza commented Mar 30, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@springfall2008 springfall2008 merged commit 0444474 into main Mar 30, 2026
1 check passed
@springfall2008 springfall2008 deleted the fix/kraken-flat-rate-null-timestamps branch March 30, 2026 18:29
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.

2 participants