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

feat: improve error logs when running sync/diff/validate #976

Merged
merged 2 commits into from
Jul 19, 2023

Commits on Jul 19, 2023

  1. feat: improve error logs when running sync/diff/validate

    Currently decK doesn't return very useful and descriptive
    errors when configuration files are validated. This is
    particularly painful when the configuration is distributed
    in several files and the error doesn't specificy which
    file contains the error.
    
    Let's take for example the following files:
    
    ```
    $ cat services.yaml
    services:
    - name: svc1
      host: mockbin.org
      foo: bar
    
    consumers:
    - username: good
    - name: bad
    ```
    
    If we run decK, it will return some obscure and incomplete errors:
    
    ```
    $ deck sync -s services.yaml -s consumers.yaml
    Error: reading file: validating file content: 1 errors occurred:
            services.0: Additional property foo is not allowed
    ```
    
    This commit is going to improve the way decK handles
    configuration validation error logging in order to provide
    a more useful description of the problems.
    When running decK with the new functionality, the following will
    be returned:
    
    ```
    $ ./deck sync -s services.yaml -s consumers.yaml
    Error: 2 errors occurred:
    	reading file services.yaml: validating file content: 1 errors occurred:
    	validation error: object="bar", err=services.0: Additional property foo is not allowed
    
    	reading file consumers.yaml: validating file content: 3 errors occurred:
    	validation error: object={"name":"bad"}, err=consumers.1: Must validate at least one schema (anyOf)
    	validation error: object={"name":"bad"}, err=consumers.1: username is required
    	validation error: object="bad", err=consumers.1: Additional property name is not allowed
    ```
    GGabriele committed Jul 19, 2023
    Configuration menu
    Copy the full SHA
    105df59 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a07c5d8 View commit details
    Browse the repository at this point in the history