github / github/octocatalog-diff

Octocatalog-diff is missing diffs from some nested arrays of objects

Open
#223 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
252
Forks
95
PR merge metrics
No merged PRs in 30d

Description

> Description of problem

When dealing with parameters that are contains arrays of objects, octocatalog-diff doesn't report any differences.

For instance the following Puppet resource:

```puppet
testtype { 'test':
'testparam' => {
'another-one' => {
'an-array' => [
{
'env' => [
{ 'name' => 'HOST', 'value' => 'localhost' },
]
},
]
}
}
```

Modifying any object of the `env` nested array (that is the keys or the values), or adding or removing objects from it will not trigger any diff to be displayed.

> Command used and debugging output

```sh
octocatalog-diff --debug --fact-file ci/facts/ubuntu.yaml --from-fact-override "role=k8s" --to-fact-override "role=k8s" --bootstrap-environment "V=1" --display-detail-add --from origin/production --master-cache-branch origin/production
```
The above commands just generate the following warning regarding the resource:
```
W, [2020-05-14T06:30:36.666653 #1771] WARN -- : Resource key testtype[test] parameters => testparam => another-one => an-array[0] => env appears to depend on catalog compilation directory. Suppressed from results.
```

Note that there's no mention of the compilation directory in the parameters value, so there's no reason for it to be ignored.

Running with `--display-datatype-changes` still doesn't display the changes, but produces the following debug log:
```
D, [2020-05-13T12:03:46.273101 #1] DEBUG -- : Adjust display for testtype::test::parameters::testparam::another-one::an-array[0]::env: nil != nil DELETED
```
Interesting, apparently octocatalog-diff thinks both before and after parameters are `nil`.

After looking at the code and debugging, it appears that the values of those nested parameters are removed in `hashdiff_nested_changes` and more precisely in `dig_out_key`.
Indeed, `dig_out_key` doesn't seem to support array indices (like `an-array[0]`) as key names and thus bails out returning nil without descending into the pointed object.

> Platform and version information

- Your OS: ubuntu bionic 18.04
- Your Ruby version: 2.5.1p57
- Your version of Puppet: 5.5.17
- Your version of octocatalog-diff: 1.6.0

> Do the tests pass from a clean checkout?

Yes.

> Anything else to add that you think will be helpful?

A PR will soon be published to fix this issue :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.