Skip to content

feat: Add Protocol Buffers Well-Known Types transformation support#206

Open
requilence wants to merge 2 commits intosoc221b:mainfrom
requilence:pretty-well-known-types
Open

feat: Add Protocol Buffers Well-Known Types transformation support#206
requilence wants to merge 2 commits intosoc221b:mainfrom
requilence:pretty-well-known-types

Conversation

@requilence
Copy link

Summary

This PR adds support for transforming Protocol Buffers Well-Known Types into more readable formats in the gRPC DevTools message viewer.

Motivation

When debugging gRPC services that use Protocol Buffers Well-Known Types (like google.protobuf.Struct, google.protobuf.Value, etc.),
the raw protobuf representation can be difficult to read. For example, a simple struct appears as:

{
  "fieldsMap": [
    ["key1", { "kind": "stringValue", "stringValue": "value1" }],
    ["key2", { "kind": "numberValue", "numberValue": 42 }]
  ]
}

This PR transforms such structures into clean, readable JSON:

  {
    "key1": "value1",
    "key2": 42
  }

Features

New Checkboxes

  1. Struct/Value - Transforms Protocol Buffers Well-Known Types:
    - google.protobuf.Struct → Regular JSON objects
    - google.protobuf.Value wrappers → Unwrapped values
    - google.protobuf.ListValue → Regular arrays
    - google.protobuf.Duration → Human-readable format (e.g., "3500ms")
    - google.protobuf.FieldMask → Comma-separated paths
  2. Remove List - Removes the List suffix from repeated field names:
    - recordsList → records
    - Only visible when Struct/Value is enabled
    - Only affects arrays, not fields like todoList: "string"

Implementation Details

  • Both checkboxes work independently and persist their state
  • Transformations apply to both Preview (tree view) and raw JSON modes
  • Follows existing patterns for conditional UI elements (like Sticky Scroll)
  • Comprehensive test coverage for all transformation cases

Testing

  • Added 17 unit tests covering all Well-Known Types transformations
  • Tests verify both enabled and disabled states
  • Tests ensure List suffix removal is properly conditional

Breaking Changes

None. All changes are additive and opt-in via checkboxes.

Screenshots

Before
Screenshot 2025-06-05 at 19 34 51
After
Screenshot 2025-06-05 at 19 34 58

🤖 Created with help of Claude Code

…vTools

  - Add Struct/Value checkbox to transform protobuf Well-Known Types
  - Transform Struct fieldsMap arrays to regular JSON objects
  - Unwrap Value types (stringValue, numberValue, etc.) to primitives
  - Convert ListValue to regular arrays
  - Transform Duration to human-readable format (e.g., "3500ms")
  - Transform FieldMask to comma-separated string
  - Add separate "Remove List" checkbox for removing 'List' suffix from arrays
  - Both transformations work in Preview and raw JSON modes
  - Settings persist across sessions
@soc221b soc221b force-pushed the pretty-well-known-types branch from ce5cca0 to df9ac32 Compare June 28, 2025 01:11
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