Java JSON serializer emits invalid extension keys by default

Open
#27,499 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #28680 by @kamilkrzywanski — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java

Research direction

Start at java/util/src/main/java/com/google/protobuf/util/JsonFormat.java around line 1175 and compare the default extension-name path with printingFullyQualifiedExtensionNames(). Determine the compatible resolution for invalid or duplicate keys, then verify that extension serialization and parsing behavior remain consistent.

Written by the indexing model from the issue text.

Description

bug java json keep open

The Java JSON serializer emits extensions using their short names here:
https://github.com/protocolbuffers/protobuf/blob/382f6a7eaf00f120afbc800723af7d67dd06ab63/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L1175

For example, an extension foo.bar will be emitted as "bar": "value" instead of "[foo.bar]": "value".

The resulting JSON is unparseable in any language, unless the extension's short name happens to clash with another field name. In that case it will result in silent data corruption. It can also lead to JSON with duplicate keys (i.e. data loss) if two extensions have the same short name.

As of 35.0 this has a fix that can be opted into by calling printingFullyQualifiedExtensionNames(). But it can't be enabled by default without a breaking change

Dominant language
C++
Stars
72.2k
Forks
16.4k
Avg merge
1d 8h
Merged PRs (30d)
342

Getting set up

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.

More from protocolbuffers/protobuf

All issues in protocolbuffers/protobuf

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.