Found the solution, theThe issue was that the field was referencingused to reference unpublished nodes that are not published soand kept throwing the error. So I updated the field to default allow unpublished content as well and itnodes too. It worked.