protocolbuffers / protocolbuffers/protobuf

Feature request: option for JsonFormat.Printer to fail if unknown fields are encountered

Open
#28,922 3 comments 0 reactions 1 assignee View on GitHub

@esrauchg is already working on this.

Since Jul 30, 2026.

feature request json
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

Currently, com.google.protobuf.util.JsonFormat.Printer silently ignores unknown fields. It would be nice to have a proactive safety check that would fail if the passed in MessageOrBuilder had unknown fields. Ideally, this would apply recursively to any nested messages, and also account for unknown fields in well known message types as well.

While encountering an unknown fields at this layer is most likely an application-level error (that is, the application probably deserialized some binary data without checking if there were any unknown fields, and then later on decided to serialize it as JSON), it would be nice to have a built-in option for this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.