Range randomly skipping entry

I have a shortcode that creates a carousel of items from all pages with a specific type in their front matter. Everything works fine except that 20% of the time one of the items is missing. This isn’t much of a problem locally because I can just rebuild and get it back, but in our CI pipeline it is almost always missing.

The shortcode “person_carousel.html” has the range:

{{ range where .Site.Pages "Type" "=" (.Get 0) }}
{{ if gt (len .Content) 0 }} <!-- No idea why, but getting an extra document with no content (also looping over the archetypes maybe?) -->

    Code and stuff...

{{ end }} <!-- End of check that there is non-zero Content -->
{{ end }} <!-- End of loop over all documents with the specified type -->

And the pages that should be entries have the front matter:

type = "carousel_entry"
layout = "null"

(the null layout is so that they don’t also be turned into normal pages too)

Then on a particular page where I want the carousel I have:

{{< person_carousel carousel_entry >}}

Shouldn’t the range be completely deterministic? To stress my point - I get different output if I rebuild with no changes whatsoever. It doesn’t appear to follow any logic, sometimes it builds fine 5 times in a row, sometimes fails several times in a row, basically randomly.
Hugo version is “Hugo Static Site Generator v0.32.2 linux/amd64 BuildDate: 2018-01-03T09:54:32Z”

Thanks for any pointers

From the information provided I can only suggest to replace .Site.Pages with .Site.RegularPages and then drop the first if statement (you won’t need that one with .Site.RegularPages). That way you can at least rule out that the if statement causes you problems.

Without seeing the code, how you call the shortcode, and understanding what it means that ‘one of the items is missing’ I can’t offer more suggestions. Perhaps someone else can. :slight_smile:

Thanks for the tip on RegularPages.
By ‘one of the items is missing’ I meant that the range skips out one of the required pages, so the end result is missing an entry.
I tried with Hugo v0.42.2 and the problem seems to have disappeared (with no change at all to the site). It’s hard to be sure since it was intermittent anyway, but I’ve rebuilt the site many times and not yet hit the same problem.