Skip to content

fix: parse whole-second protobuf duration strings like 0s#58

Open
aadi-joshi wants to merge 1 commit into
Kaggle:mainfrom
aadi-joshi:fix/timedelta-whole-second-durations
Open

fix: parse whole-second protobuf duration strings like 0s#58
aadi-joshi wants to merge 1 commit into
Kaggle:mainfrom
aadi-joshi:fix/timedelta-whole-second-durations

Conversation

@aadi-joshi

Copy link
Copy Markdown

Summary

Fix TimeDeltaSerializer._from_dict_value to accept protobuf JSON duration strings without a fractional component (e.g. 0s, 151s). The current implementation always splits on ., which crashes quota and other API responses that return whole-second durations.

Needs manual sync with the kapigen base.

Root cause

(seconds, nanosRaw) = value.rstrip("s").split(".")

Protobuf JSON allows whole-second values like 0s. When .split(".") returns one element, unpacking fails with ValueError: not enough values to unpack (expected 2, got 1).

Reported in Kaggle/kaggle-cli#1064.

Tests

Added TimeDeltaSerializerTests in kaggle_object_tests.py:

  • whole-second durations (0s, 151s)
  • fractional durations (151.500s) regression
  • ApiGetAcceleratorQuotaStatisticsResponse JSON deserialization

Test plan

  • TimeDeltaSerializer._from_dict_value("0s") returns timedelta(0)
  • CI: python -m unittest kaggle_object_tests.TimeDeltaSerializerTests

Needs manual sync with the kapigen base.
aadi-joshi added a commit to aadi-joshi/kaggle-cli that referenced this pull request Jun 30, 2026
@aadi-joshi

Copy link
Copy Markdown
Author

Following up on stevemessick's guidance in Kaggle/kaggle-cli#1082. Marked for manual sync with the kapigen base. The auth portion of Kaggle/kaggle-cli#1064 is handled separately in #1082.

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.

1 participant