Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to run protolint lint . and get go syntax error #218

Open
DoneSpeak opened this issue Feb 22, 2022 · 5 comments
Open

Fail to run protolint lint . and get go syntax error #218

DoneSpeak opened this issue Feb 22, 2022 · 5 comments
Labels
good first issue Good for newcomers

Comments

@DoneSpeak
Copy link

I install protolint with brew install protolint and run protolint lint . to verify the following proto file.

message Book {
    optional string name = 1;
}

but getting error result:

$ protolint lint .                                                       
found "\"message\"(Token=27, Pos=tests/test.proto:1:1)" but expected [syntax] at /home/runner/go/pkg/mod/github.com/yoheimuta/go-protoparser/v4@v4.5.3-0.20220212052745-6d78fe6fbe7b/parser/syntax.go:62. Use -v for more details

How can I fix the problem?

What's more, I want to create my Dockerfile installed protolint and using the image to run pre-commit. I get a same result in the ci.

The project: https://gitlab.com/DoneSpeak/container-image

Here is the docker file:

# syntax=docker/dockerfile:1
FROM golang:1.17.7-bullseye

RUN apt-get update
RUN apt-get -y install python3
RUN apt-get -y install python3-setuptools
RUN apt-get -y install python3-pip

RUN pip install pre-commit==2.17.0
RUN pip install yamllint==1.26.3
RUN mkdir -p /opt/protolint
RUN curl -L https://github.com/yoheimuta/protolint/releases/download/v0.37.0/protolint_0.37.0_Linux_x86_64.tar.gz | tar -xz -C /opt/protolint
RUN ln -s /opt/protolint/protolint /usr/local/bin/protolint

The fail ci job is pre-commit ci job.

another docker file is:

# syntax=docker/dockerfile:1
FROM python:3.8.12-buster

RUN pip install pre-commit==2.17.0
RUN pip install yamllint==1.26.3
RUN mkdir -p /opt/protolint
RUN curl -L https://github.com/yoheimuta/protolint/releases/download/v0.37.0/protolint_0.37.0_Linux_x86_64.tar.gz | tar -xz -C /opt/protolint
RUN ln -s /opt/protolint/protolint /usr/local/bin/protolint
@DoneSpeak
Copy link
Author

Maybe I have figured out the reason. The parse requires a syntax key world in the protobuf file which I didn't provide. I think it should be a verify error like the following content instead of a code error which makes me very confused.

[tests/test.proto:4:3] Field "query" should avoid required for proto3

@yoheimuta
Copy link
Owner

@DoneSpeak

Maybe I have figured out the reason.

That's right.

I think it should be a verify error like the following content instead of a code error which makes me very confused.

I agree with you. The parser should make the error message clearer.

@yoheimuta yoheimuta added the good first issue Good for newcomers label May 3, 2022
@CorrM
Copy link

CorrM commented Aug 1, 2022

Same here

image
image

@ricsiLT
Copy link

ricsiLT commented Sep 12, 2022

Yours is different but related to protolint not being able to parse UTF-8-BOM files :D for now just save them as UTF-8 but it should be fixed - no reason this can't be handled.

@yoheimuta
Copy link
Owner

Thank you for clarifying the issue.

Handling UTF-8 BOM (U+FEFF) properly seems worth it.
Whenever I have time, I'm getting to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants