Skip to content

Conversation

@sudo-suhas
Copy link
Contributor

@sudo-suhas sudo-suhas commented Nov 7, 2022

  • Include plugin name in the error message when it is not found.
  • Include the validation failure message along with the line number in
    the error message for plugin config.
  • During lint, include the recipe name while printing errors that are
    neither 'not found' nor 'invalid config' errors.
  • During run, on run failure, include recipe name in the error log
    context.
  • Include details of the validation failures in the error message for
    InvalidConfigError. This gets printed while trying to run the recipe.

BEFORE:

$ meteor run run ./_recipes/caramlstore-stg-wth-script-invalid.yaml
INFO[0000] running recipe                                recipe=caramlstore-stg-wth-script-invalid
ERRO[0000] error running recipe                          duration_ms=189 err="failed to setup processor: could not initiate processor \"script\": script processor init: invalid  config" recipe=caramlstore-stg-wth-script-invalid records_count=0
ERRO[0000] failed to setup processor: could not initiate processor "script": script processor init: invalid  config
...

$ meteor lint ./_recipes
caramlstore-stg-wth-script-invalid: invalid script processor config on line: 13
caramlstore-stg-wth-script-invalid: invalid script processor config: Key: 'Config.script' Error:Field validation for 'script' failed on the 'required' tag
recipe error: urn scope is required to generate unique urn
kafka-to-http: invalid labels processor config: Key: 'Config.labels' Error:Field validation for 'labels' failed on the 'required' tag
service_yaml-test: invalid extractor on line: 4
shield-integration: invalid shield extractor config: Key: 'Config.host' Error:Field validation for 'host' failed on the 'required' tag
...

AFTER:

$ meteor run run ./_recipes/caramlstore-stg-wth-script-invalid.yaml
INFO[0000] running recipe                                recipe=caramlstore-stg-wth-script-invalid
ERRO[0000] error running recipe                          duration_ms=205 err="failed to setup processor: could not initiate processor \"script\": script processor init: invalid config:     * validation for field 'engine' failed on the 'oneof' tag\n\t * validation for field 'script' failed on the 'required' tag" recipe=caramlstore-stg-wth-script-invalid records_count=0
ERRO[0000] failed to setup processor: could not initiate processor "script": script processor init: invalid config:
     * validation for field 'engine' failed on the 'oneof' tag
     * validation for field 'script' failed on the 'required' tag  recipe=caramlstore-stg-wth-script-invalid
...

$ meteor lint ./_recipes
caramlstore-stg-wth-script-invalid: invalid script processor config on line: 13: validation for field 'engine' failed on the 'oneof' tag
caramlstore-stg-wth-script-invalid: invalid script processor config: validation for field 'script' failed on the 'required' tag
kafka-to-http: recipe error: urn scope is required to generate unique urn
kafka-to-http: invalid labels processor config: validation for field 'labels' failed on the 'required' tag
service_yaml-test: invalid 'service_yaml' extractor on line: 4
shield-integration: invalid shield extractor config: validation for field 'host' failed on the 'required' tag

Closes #416

@sudo-suhas sudo-suhas force-pushed the improve-err-msgs branch 2 times, most recently from 02d0701 to 54be760 Compare November 8, 2022 04:30
@sudo-suhas sudo-suhas force-pushed the improve-err-msgs branch 2 times, most recently from f51a759 to 919d50d Compare November 22, 2022 09:49
@ravisuhag
Copy link
Member

@sudo-suhas can you also add test cases for maintaining code coverage? The pipeline will break without that.

- Include plugin name in the error message when it is not found.
- Include the validation failure message along with the line number in
  the error message for plugin config.
- During lint, include the recipe name while printing errors that are
  neither 'not found' nor 'invalid config' errors.
- During run, on run failure, include recipe name in the error log
  context.
- Include details of the validation failures in the error message for
  InvalidConfigError. This gets printed while trying to run the recipe.

BEFORE:

    $ meteor run run ./_recipes/caramlstore-stg-wth-script-invalid.yaml
    INFO[0000] running recipe                                recipe=caramlstore-stg-wth-script-invalid
    ERRO[0000] error running recipe                          duration_ms=189 err="failed to setup processor: could not initiate processor \"script\": script processor init: invalid  config" recipe=caramlstore-stg-wth-script-invalid records_count=0
    ERRO[0000] failed to setup processor: could not initiate processor "script": script processor init: invalid  config
    ...

    $ meteor lint ./_recipes
    caramlstore-stg-wth-script-invalid: invalid script processor config on line: 13
    caramlstore-stg-wth-script-invalid: invalid script processor config: Key: 'Config.script' Error:Field validation for 'script' failed on the 'required' tag
    recipe error: urn scope is required to generate unique urn
    kafka-to-http: invalid labels processor config: Key: 'Config.labels' Error:Field validation for 'labels' failed on the 'required' tag
    service_yaml-test: invalid extractor on line: 4
    shield-integration: invalid shield extractor config: Key: 'Config.host' Error:Field validation for 'host' failed on the 'required' tag
    ...

AFTER:

    $ meteor run run ./_recipes/caramlstore-stg-wth-script-invalid.yaml
    INFO[0000] running recipe                                recipe=caramlstore-stg-wth-script-invalid
    ERRO[0000] error running recipe                          duration_ms=205 err="failed to setup processor: could not initiate processor \"script\": script processor init: invalid config:     * validation for field 'engine' failed on the 'oneof' tag\n\t * validation for field 'script' failed on the 'required' tag" recipe=caramlstore-stg-wth-script-invalid records_count=0
    ERRO[0000] failed to setup processor: could not initiate processor "script": script processor init: invalid config:
         * validation for field 'engine' failed on the 'oneof' tag
         * validation for field 'script' failed on the 'required' tag  recipe=caramlstore-stg-wth-script-invalid
    ...

    $ meteor lint ./_recipes
    caramlstore-stg-wth-script-invalid: invalid script processor config on line: 13: validation for field 'engine' failed on the 'oneof' tag
    caramlstore-stg-wth-script-invalid: invalid script processor config: validation for field 'script' failed on the 'required' tag
    kafka-to-http: recipe error: urn scope is required to generate unique urn
    kafka-to-http: invalid labels processor config: validation for field 'labels' failed on the 'required' tag
    service_yaml-test: invalid 'service_yaml' extractor on line: 4
    shield-integration: invalid shield extractor config: validation for field 'host' failed on the 'required' tag
    ...
@sudo-suhas
Copy link
Contributor Author

sudo-suhas commented Nov 23, 2022

Have added tests where possible but haven't added any tests for the logging changes. W.r.t coverage, we aren't measuring the coverage for tests that have the //go:build plugins tag. Also, the way we calculate the difference in coverage is incorrect(check https://coveralls.io/builds/54400061 for example). See #429.

@StewartJingga StewartJingga self-requested a review November 23, 2022 07:21
@sudo-suhas sudo-suhas merged commit bc3164e into main Nov 23, 2022
@sudo-suhas sudo-suhas deleted the improve-err-msgs branch November 23, 2022 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhelpful error message on validation error

4 participants