|
Having duplicate input (paths) in a hiera.yaml is currently allowed since it is logically harmless (the same result is produced as if only the first entry was present). It is however a) a missed optimization or worse b) the user made a copy/paste mistake.
There is also an issue when given paths contain interpolation and the interpolated result set contains duplicate pats.
The way to handle the various ways to specify the "path" in a hiera.yaml entry differs as follows:
-
path - a single path - no problem with uniqueness
-
paths - if given paths before interpolation are not unique issue an error. (Help user with copy/paste error). If given paths after interpolation are not unique, output this in --explain output and as a warning.
-
mapped_paths - since this is a formula that produces multiple paths, it is not meaningful to produce the same path multiple times. Any problem in this case would be that the input to the formula is not formed as intended (for example; missing information makes paths alike because undef renders as an empty string). For this case, the --explain output should show the map from input to output including the non unique paths, and state that the non unique paths were ignored. Basically like paths, but with mapping information present in explain output so user can find the source of the problem.
-
uri - single entry, no processing
-
uris - same treatment as for paths
The fact that undef produces an empty string and that this is accepted is another separate problem. A user should probably have control over the optionality of an interpolation.
There is also a problem if the same path/uri is used in multiple entries for the same backend with the same options (i.e. the same pattern as for a single entry at a larger scale). The reasons for ending up with that are the same as for a single entry (unexpected interpolated values, copy/paste errors). For that reason, the static uniqueness should apply to the entire hiera.yaml. The "after interpolation" (dynamic) checking is probably a performance issue if it were to be done for all entries as it requires interpolating all paths "below" even if a value is found early.
|