redpanda-data / redpanda-data/benthos

template lint without parameters return false positive

Open
#150 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

annoying needs investigation
Dominant language
Go
Stars
571
Forks
120
Avg merge
2d 1h
Merged PRs (30d)
18

Description

This is the help message from redpanda connect

$ docker  run --rm redpandadata/connect:4.42 template lint --help
NAME:
   redpanda-connect template lint - Parse Redpanda Connect templates and report any linting errors

USAGE:
   redpanda-connect template lint [command options]

DESCRIPTION:
   Exits with a status code 1 if any linting errors are detected:

     redpanda-connect template lint
     redpanda-connect template lint ./templates/*.yaml
     redpanda-connect template lint ./foo.yaml ./bar.yaml
     redpanda-connect template lint ./templates/...

   If a path ends with '...' then Redpanda Connect will walk the target and lint any
   files with the .yaml or .yml extension.

OPTIONS:
   --env-file value, -e value [ --env-file value, -e value ]    import environment variables from a dotenv file
   --templates value, -t value [ --templates value, -t value ]  EXPERIMENTAL: import Redpanda Connect templates, supports glob patterns (requires quotes)
   --help, -h                                                   show help

based on this, this option is valid redpanda-connect template lint that does nothing (?)

and since there is an option -t I made a mistake and I did not add the templates files as an argument of template lint and it give me a false positive

for instance, if the template is ok, both commands exit with success

$ docker run --rm -v ./templates:/t redpandadata/connect:4.42 template lint -t "/t/*.yaml"
$ docker run --rm -v ./templates:/t redpandadata/connect:4.42 template lint "/t/*.yaml"

however, if I change one unit test to force a failure, the first command will not execute the unit tests.

what I expect: same behavior as test

$ docker run --rm -v ./config:/c redpandadata/connect:4.42 test
No tests were found

$ echo $?
1

BTW the command lint also return a false positive if no files are specified (and the help description does not show this possibility

$ docker run --rm -v ./config:/c redpandadata/connect:4.42 lint

$ echo $?
0

$ docker run --rm -v ./config:/c redpandadata/connect:4.42 lint help
NAME:
   redpanda-connect lint - Parse Redpanda Connect configs and report any linting errors

USAGE:
   redpanda-connect lint [command options]

DESCRIPTION:
   Exits with a status code 1 if any linting errors are detected:

     redpanda-connect lint ./configs/*.yaml
     redpanda-connect lint ./foo.yaml ./bar.yaml
     redpanda-connect lint ./configs/...

   If a path ends with '...' then Redpanda Connect will walk the target and lint any
   files with the .yaml or .yml extension.

what I expect:

  • if I call test, lint or template lint, I expect a failure message and exit code != 0 if no files are specified (it could be a mistake)
  • will be wonderful some kind of "verbose" option where we show the files linted /tested and what are the tests executed

Regards

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 reproducing the no-argument behavior for the test, lint, and template lint CLI entry points, including template lint -t, using the commands and expected exit codes in the issue. Trace how input paths and template parameters are handled, then verify that missing inputs fail and that -t causes the intended files to be linted. The verbose-output request is an additional scope to assess separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, testing-qa
Issue type
Bug
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.