Skip to content

fix(table): flatten nested objects to dot-notation, safe multi-byte truncation (fixes #40 #43)#51

Merged
jpoehnelt merged 2 commits intomainfrom
fix/table-flatten-and-unicode
Mar 4, 2026
Merged

fix(table): flatten nested objects to dot-notation, safe multi-byte truncation (fixes #40 #43)#51
jpoehnelt merged 2 commits intomainfrom
fix/table-flatten-and-unicode

Conversation

@jpoehnelt
Copy link
Copy Markdown
Member

Fixes #40
Fixes #43

Changes

Nested Object Flattening (issue #40)

  • Added flatten_object() helper that recursively converts {"user": {"name": "Alice"}} into [("user.name", "Alice")]
  • format_table_page and format_array_as_table now use flattened rows, so nested API response objects appear as readable dot-notation columns instead of raw JSON blobs
  • Applies to both single-object tables (drive about get) and array tables (drive files list)

Multi-byte Truncation Panic Fix (issue #43)

  • Replaced byte-slice truncation &c[..widths[i]-1] with char-based: c.chars().take(n).collect::<String>()
  • Column widths are now tracked and compared by Unicode character count, not byte length
  • Custom per-char padding replaces format!("{:width$}") which was also byte-based

Tests Added

  • test_format_table_nested_object_flattened: verifies dot-notation keys, no raw JSON blobs
  • test_format_table_nested_objects_in_array: verifies flattening in array rows
  • test_format_table_multibyte_truncation_does_not_panic: 70 emojis (4 bytes each) — no panic
  • test_format_table_multibyte_exact_boundary: accented characters do not corrupt output

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: f91f9e0

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jpoehnelt jpoehnelt merged commit e41bd89 into main Mar 4, 2026
22 checks passed
@jpoehnelt jpoehnelt deleted the fix/table-flatten-and-unicode branch March 4, 2026 08:01
shigechika pushed a commit to shigechika/gws-cli that referenced this pull request Mar 20, 2026
…flatten-and-unicode

fix(table): flatten nested objects to dot-notation, safe multi-byte truncation (fixes googleworkspace#40 googleworkspace#43)
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.

Bug: Panic on Multi-byte Characters in format_array_as_table ux: --format table shows raw JSON blobs for nested objects

1 participant