protocolbuffers / protocolbuffers/protobuf
Ruby deprecated descriptors should throw ruby warnings
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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