Diffable Data Source "Invalid section definition" error

When we attempt to apply a new snapshot for reloading the data, we receive this error.

Invalid section definition. Please specify a valid section definition when content is to be rendered for a section. This is a client error.

We tried debugging by following some similar answers:

  • Invalidating our compositional layout
  • Reusing the current snapshot and wiping it before applying the new ones

The only thing that seems to work is to dispatch the apply method into the main thread. But we are already on the main thread in all cases where we enter this method. So it's just dispatching into the main thread again.

This error also never happens the first time we apply the snapshot. Inspecting the snapshot.sectionIdentifiers and the data shows the expected definitions. So we are kind of stumped on this one.

Turns out we had to apply the new collectionViewLayout before applying the snapshot.

Diffable Data Source "Invalid section definition" error
 
 
Q