Diagram: GET /legalHolds?$top=999 returns page one plus @odata.nextLink. Reading page one only gives a false No Hold Found. The fix is Pagination on, so every page is merged.

A compliance check has two ways to be wrong. It can fail loudly, which is annoying but honest. Or it can succeed on half the data and report the answer with full confidence. This post is about the second kind, and it’s the most ordinary bug in the series.

If you’re joining here, the first post describes the system. Membership of one Entra group drives Purview legal holds through two scheduled Power Automate flows, Add and Remove, and the Microsoft Graph eDiscovery (Premium) API. Each person gets one hold, named from their UPN, like LH-Bot-jane.doe_contoso.com. Before Add creates anything, it looks for an existing hold in both cases. Remove finds a person’s hold by matching their mailbox in the hold’s user sources, then rewrites the end date in its query.

Both of those are lookups. Both depend on seeing every hold.

The symptom

Holds that clearly existed weren’t found.

On the Add side, the flow tried to create holds that were already there. On the Remove side, it could mark a row No Hold Found for a person whose hold was sitting in the case. In this system, that status isn’t a quiet note in a list. It sends an URGENT email, [URGENT] NO legal hold for removed user, because a person leaving the group with no hold to close is something legal needs to know about straight away.

So the false result didn’t just sit in a column. It sent people chasing a gap in preservation that wasn’t there, and the record said the control had looked and found nothing.

A false “No Hold Found” is worse than an error, because it looks like an answer.

No Hold Found also has perfectly ordinary causes: someone was removed before the system went live, a hold was created by hand without sources, or the UPN doesn’t match the source address. A false one blends in with the real ones. That’s part of why it took us a while to see it.

What we assumed

Every list call in both flows carried the same parameter:

GET /legalHolds?$top=999
GET /custodians?$top=999

The intent was obvious from the code. Give us everything, there won’t be more than 999. The flow then read the value array from the response and moved on.

That reads like a complete list. It’s the kind of line that passes review because nobody questions it, and it was in every collection read we had.

We had treated $top as a promise about how much would come back, and it isn’t one.

The fixes that didn’t reach page two

We didn’t find this by looking for it. We found it while chasing the 409 from post 2.

The first fix in that story, v1.0.4.12, was about name scope. Purview hold names are unique across the whole tenant, so the flow started listing holds in Case B and then Case A, filtering on displayName, and reusing any hold whose name already existed. That was a real correction, and it was the right check.

It was also reading the same list. The name check filtered whatever came back from the first response, so a hold that lived beyond it was still invisible. The check was correct about the holds it could see and silent about the rest. A name that was taken looked free.

The same was true of the source scan. Matching a person’s mailbox against each hold’s user sources is a sound way to find their hold, as long as you’ve actually read every hold and every source.

A correct check on incomplete data still gives the wrong answer.

We’ll be honest about the other half too. When we fixed paging in v1.0.4.13, the 409 continued. Paging was a real bug that made the flow wrong in its own right, but it wasn’t the cause of that error. Post 2 tells the rest of that story.

What was actually happening

Microsoft Graph decides how much to return in a single response. $top asks for a page size. Graph can page the result anyway, return the first page, and add an @odata.nextLink property pointing at the next one.

Our flows read the first response and stopped. They never looked for @odata.nextLink, so everything after the first page was invisible to both the source scan and the name check.

Nothing failed. The HTTP action got a response with holds in it, the flow processed them, and every downstream decision was made on a partial list with no sign that it was partial.

Paging isn’t an error condition, so nothing in the run history tells you you’ve missed it.

It also hides well in testing. A test case with a handful of holds fits comfortably on the first page, so a flow that ignores @odata.nextLink passes every test you give it. The bug only appears as the case fills up, which in a legal-hold system means it appears in production, on the busiest case, after people have started trusting the results. The more successful the automation is, the more holds there are, and the more of them sit beyond the first page.

Two columns. Left, reading one response: the flow takes the value array, ignores @odata.nextLink, and holds on page two are never seen. Right, following nextLink: Power Automate pagination fetches every page and merges them, so the name check and source scan see every hold

The fix: let Power Automate follow the link

Power Automate already knows how to do this. The HTTP action has a Pagination setting in its settings pane, with a threshold. Turn it on, and Power Automate follows @odata.nextLink itself and merges every page into one value array before the next action runs. The rest of the flow doesn’t change: the filters, the loops and the name checks all keep reading the same array, which is now complete.

We turned it on for every Graph collection GET in both flows. There were three reads in each:

  • the legal holds list, which feeds the name check and the existing-hold search
  • the custodians list, used when a new hold is created
  • a hold’s user sources, which is how Remove matches a person’s mailbox to their hold

The fix shipped in Add v1.0.4.13 and Remove v1.0.3.5.

We didn’t stop at the one read that had visibly failed. If one collection read can be paged, every collection read can, so the setting goes on all of them, including the ones that look small today.

Three numbered rows, one per collection read fixed in both flows: the legal holds list behind the name check and existing-hold search, the custodians list used on new holds, and a hold's user sources, which Remove uses to match a person's mailbox

Two practical notes. Set the threshold above the largest collection you expect to hold, with room to grow, because the threshold is a ceiling and pagination stops when it reaches it. And keep $top if you like. It still sets the page size you’re asking for. It just doesn’t decide how many pages there are.

The rule to take away

The technical rule is short. Every Microsoft Graph collection read needs paging, even when you’re sure the collection is small. In Power Automate that means the Pagination setting on every HTTP GET that returns a collection, with a threshold that leaves room for growth. “We only have a few hundred” stops being true right before an audit.

A checklist for paging Microsoft Graph in Power Automate: turn on Pagination for every collection GET, set the threshold above the largest expected collection, include the small collections, treat $top as page size only, leave the downstream logic reading one merged value array, and test against a collection bigger than one page

The governance lesson is the one we’d put in front of a CIO. A guardrail that misses page two isn’t a guardrail. Completeness is part of the control. A check that reads only the first page doesn’t fail. It gives false assurance: a No Hold Found that sends people chasing a gap that isn’t there, a name that looks free when it isn’t, a duplicate create against a hold that already exists.

The question an auditor will ask isn’t “did the check run?” It’s “how do you know the check saw everything?” If the honest answer is “it saw the first page Graph chose to send”, the control is weaker than its record suggests, and nobody can see that from the outside.

This is the same habit as post 4, applied to reads instead of writes. There, the lesson was not to trust a response code to describe the hold. Here, it’s not to trust one response to describe the collection.

That’s the layer IT owns. The business can and should shape more of its own AI and automation, but that only lasts on guardrails that hold up in an audit. Legal set the rule here. Making it provable meant making sure the flow looked at every hold, not just the first batch it was handed.

Next: where Purview hides contentQuery.

The engagement behind this series was for a large enterprise client. Names, domains, hold prefixes and identifiers have been replaced throughout. Error messages, endpoints and platform behaviour are reported exactly as observed.

CB5 Solutions helps organizations understand the layers of AI, get the most from what they buy, and build an AI program that pays back inside their IT standards. We start every engagement with one business problem and a governance baseline. Let’s pick yours.