protocolbuffers / protocolbuffers/protobuf

Ruby deprecated descriptors should throw ruby warnings

Open
#2,275 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted ruby
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

To keep things backwards compatible and follow semver.org when working with our protobufs, we would like to be able to use the deprecated option: int32 old_field = 3 [deprecated=true];

This would be great if it notified the downstream consumer that the field had been deprecated. As is standard practice in ruby, this is typically done with a warning.

https://ruby-doc.org/core-2.2.0/Kernel.html#method-i-warn

This could be done simply by outputing:

warn("DEPRECATION WARNING: Field #{field_name} for message #{message_name} is deprecated, consider removing references to it")

If this is output then when one of our downstream clients upgrades to a new minor version, their code will work but will include warnings that warn about the now deprecated fields in use. If they don't reference (get or set) the field or other descriptor type, then they will get no warnings. Providing descriptor name and as much detail as possible will help the user debug their code and remove the deprecated fields.

Currently the approach is to either reserve or rename the field. This works until they update their schema, then it will start failing. This keeps the data message backwards compatible but not the generated code. Adding the deprecation warning will assist in this manner.

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 with the Ruby descriptor access paths described in the issue and Ruby's Kernel#warn behavior. Verify that referencing a deprecated field or descriptor emits the requested warning, while accesses to non-deprecated fields do not; the issue does not name specific files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend-api-design
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.