fix: parse whole-second protobuf duration strings like 0s#58
Merged
stevemessick merged 1 commit intoJul 1, 2026
Merged
Conversation
Needs manual sync with the kapigen base.
2 tasks
aadi-joshi
added a commit
to aadi-joshi/kaggle-cli
that referenced
this pull request
Jun 30, 2026
Related to Kaggle#1064. Duration parsing fix is in Kaggle/kaggle-sdk-python#58.
Contributor
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. |
stevemessick
pushed a commit
to Kaggle/kaggle-cli
that referenced
this pull request
Jul 1, 2026
## Summary Fix `_is_help_or_version_command` so subcommand `-v` (the CSV output alias on commands like `quota`) no longer skips authentication. Top-level `kaggle -v` / `kaggle --version` still skip auth as before. The duration parsing crash from #1064 is handled separately in Kaggle/kaggle-sdk-python#58 (needs kapigen sync and a new kagglesdk release). ## Root cause `authenticate()` runs before argparse and joins `sys.argv[1:]` into a string. `"quota -v".endswith("-v")` matched the global version check even though `-v` here is the CSV flag, causing unauthenticated API calls and 401s. ## Tests Added `tests/unit/test_help_version_auth.py` covering top-level version/help, subcommand CSV `-v`, and subcommand help. ## Test plan - [x] `pytest tests/unit/test_help_version_auth.py` - [ ] Maintainer: please run `/gcbrun` for Cloud Build (fork PR) Related to #1064
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.
Summary
Fix
TimeDeltaSerializer._from_dict_valueto 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
Protobuf JSON allows whole-second values like
0s. When.split(".")returns one element, unpacking fails withValueError: not enough values to unpack (expected 2, got 1).Reported in Kaggle/kaggle-cli#1064.
Tests
Added
TimeDeltaSerializerTestsinkaggle_object_tests.py:0s,151s)151.500s) regressionApiGetAcceleratorQuotaStatisticsResponseJSON deserializationTest plan
TimeDeltaSerializer._from_dict_value("0s")returnstimedelta(0)python -m unittest kaggle_object_tests.TimeDeltaSerializerTests