kapitan icon indicating copy to clipboard operation
kapitan copied to clipboard

Fix #491

Open ademariag opened this issue 4 years ago • 4 comments

Fixes issue #491

Proposed Changes

  • check that the generated content is a dictionary

for JSON to be valid, the content of output_obj needs to be:

{ "key": "value"}

or even just:

{}

which in both cases would be a "dict", which would make it ignore the if not isinstance(output_obj, dict) check.

This means that the only moment that check is evaluated is when, with prune: true, {} becomes NoneType.

Test

adding the following code

 56         print("output_obj is of type: ", type(output_obj))
 57         return

Without prune enabled:

output_obj is of type:  <class 'dict'> <- because it is {}

With prune enabled:

output_obj is of type:  <class 'NoneType'> <- prune makes it NoneType, and this triggers the "single file" mode

ademariag avatar Apr 23 '20 23:04 ademariag

BTW even with this patch, with prune: false Kapitan crashed quite badly. This PR does not address that issue, which I will re-open in another bug report

ademariag avatar Apr 24 '20 14:04 ademariag

Crashed for which use case? We can't merge a crashing PR. :P

uberspot avatar Apr 24 '20 14:04 uberspot

The crash is unrelated to this PR. It already exists in the current codebase. Will open another bug report :)

ademariag avatar Apr 24 '20 14:04 ademariag

@ademariag can we add tests to cover what this fix?

ramaro avatar May 07 '20 17:05 ramaro