ampproject / ampproject/amphtml
Unpin protobuf version for amp validator
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
Generating protos with [protobuf v4.21.1](https://pypi.org/project/protobuf/4.21.1/) fails. As a workaround, we pinned protobuf to v3.19.4 [here](https://github.com/ampproject/amphtml/blob/main/.circleci/install_validator_dependencies.sh#L19).
### Reproduction Steps
Run `amp validator` with protobuf 4.21.1
### Relevant Logs
```shell
validator-tests.js Running amp validator...
[17:10:01] Using task file project/amp.js
[17:10:01] Starting 'validator'...
Traceback (most recent call last):
File "build.py", line 620, in
Main(parser.parse_args())
File "build.py", line 597, in Main
GenValidatorProtoGeneratedJs(out_dir='dist')
File "build.py", line 195, in GenValidatorProtoGeneratedJs
from dist import validator_pb2
File "/home/circleci/project/validator/dist/validator_pb2.py", line 33, in
_descriptor.EnumValueDescriptor(
File "/home/circleci/.local/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 755, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
```
cc @ampproject/wg-caching
Contributor guide
Research direction
Start with .circleci/install_validator_dependencies.sh at the protobuf pin, then inspect build.py and validator/dist/validator_pb2.py around GenValidatorProtoGeneratedJs. Reproduce the failure by running amp validator with protobuf 4.21.1. Done means the validator works without the old protobuf pin and the relevant generation or validator checks pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100