Skip to content

fix(driver): handle decimal space info sizes#74

Merged
SheltonZhu merged 1 commit into
developfrom
fix/space-info-decimal-size
May 22, 2026
Merged

fix(driver): handle decimal space info sizes#74
SheltonZhu merged 1 commit into
developfrom
fix/space-info-decimal-size

Conversation

@SheltonZhu

@SheltonZhu SheltonZhu commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add custom JSON unmarshalling for 115 space size responses that may contain decimal numbers.
  • Keep public size fields as int64 while accepting decimal numeric and string payloads.
  • Add regression coverage for decimal space_info sizes.

Source

Test Plan

  • git diff --check
  • go test ./pkg/driver -run TestInfoResponseUnmarshalsDecimalSpaceSizes -count=1
  • go test ./... -run TestInfoResponseUnmarshalsDecimalSpaceSizes -count=1

Notes

  • go test ./... without filtering currently requires a valid 115 COOKIE; with an empty cookie it fails existing integration tests with bad cookie / user not login.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75b6cf9e9b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/driver/info.go
Comment on lines +108 to +111
if dot := strings.IndexByte(value, '.'); dot >= 0 {
value = value[:dot]
}
return strconv.ParseInt(value, 10, 64)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse exponent-form sizes without truncating significand

JSON numeric values may legally use exponent notation, but this logic truncates everything after the first . before parsing. For inputs like "size": 1.5e6 (or the same as a JSON string), value becomes "1", ParseInt succeeds, and the code silently records 1 byte instead of 1500000. This introduces silent data corruption for any scientific-notation payloads instead of surfacing an error.

Useful? React with 👍 / 👎.

@SheltonZhu SheltonZhu merged commit a08e2e8 into develop May 22, 2026
SheltonZhu added a commit that referenced this pull request May 22, 2026
## Summary
- Address Codex review feedback from #74 by parsing exponent-form space
size values correctly.
- Replace manual decimal truncation with high-precision numeric parsing
and integer truncation.
- Add regression coverage for numeric and string exponent payloads.

## Source
- Follow-up to Codex review on #74:
#74 (comment)
- Original issue source:
OpenListTeam/OpenList#2343

## Test Plan
- [x] `go test ./pkg/driver -run
'TestInfoResponseUnmarshals(Decimal|Exponent)SpaceSizes' -count=1`\n-
[x] `git diff --check`\n- [x] `go test ./... -run
'TestInfoResponseUnmarshals(Decimal|Exponent)SpaceSizes' -count=1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant