Hey, I have the same error, and FEniCS gives me same reason. It turns out I passed boundary condition (linked to a mixed FunctionSpace object in main function) to my user-defined function, and I also passed an Mesh object (corresponding to that mixed FunctionSpace in main function) to my user-defined function and then generated a mixed FunctionSpace object from Mesh object. So in user-defined function, the new mixed FunctionSpace object is not linked to the boundary condition, or the new mixed FunctionSpace object is different from the mixed FunctionSpace object in main function, or the boundary condition and mixed FunctionSpace object are not synchronized. So assemble_system(a, L, bcs)
cannot find boundary condition of the new mixed FunctionSpace object. Hope this is helpful in the future.