Skip to content

Bug(encode-json): Using --encode-json and --enable-console-log does not guarantee a valid JSON output #854

@erezrokah

Description

@erezrokah

Describe the Bug

When running with --encode-json and --enable-console-log, for some commands the output is not valid JSON.

Expected Behavior

When running with --encode-json and --enable-console-log the output should always be a valid JSON

CloudQuery Version

Version: 0.24.9
Commit: b5af06b570558612c95407dceb4200f92640f335
Date: 2022-06-06T13:32:45Z

Debug Output

Steps to Reproduce

cloudquery init aws
cloudquery fetch
cloudquery policy run aws --enable-console-log --encode-json

See that the output is interleaved with other output:
image

Also with --encode-json logs lines are printed to stdout and without --encode-json log lines are printed to stderr

The fix could be to change

writers = append(writers, os.Stdout)
to print to stderr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions