influxdata / influxdata/pbjson

Should be possible to deserialize unknown enum values

Open
#92 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
116
Forks
55
PR merge metrics
No merged PRs in 30d

Description

Consider the following Proto file:

message Foo {
  MyEnum my_enum = 1;
}

enum MyEnum {
  MY_ENUM_UNSPECIFIED = 0;
  MY_ENUM_BAR = 1;
  MY_ENUM_QUX = 2;
}

I'm interested in receiving JSON-encoded Foo messages where the enum might have more values added to it later, without me having to update my Proto file and re-generate code. Both of these JSON blobs deserialize fine: {"myEnum": "MY_ENUM_UNSPECIFIED"} and {"myEnum": 1}. However, these two won't work: {"myEnum": "MY_ENUM_BUX"} and {"myEnum": 100}.

It would be great if some sort of mechanism could be added to tolerate unknown enum values.

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.

Research direction

Start by locating the generated serde handling for prost enum values and compare its behavior for known numeric and string inputs. Determine how unknown enum names and numbers should be represented without updating the .proto, then add coverage for both cases; done means those JSON forms deserialize successfully while existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.