[SalesForce] SFDX Pull error: Entity of type ‘ListView’ named XXX cannot be found

While trying to pull changes from a scratch org (sfdx force:source:pull, tried with and without -f), I'm getting this error:

Entity of type 'ListView' named 'Note_Relation__c.My_Notes' cannot be found.

I do have a custom object Note_Relation__c, and it exists both locally and in the scratch org. However, it's not an object that is normally accessed directly. It has no tab, and should have no list views. Nonetheless, I've checked the object's list view (via prefix, e.g., /a0D in both Classic and LEX view), and I can find no list views at all. I've also tried adding an entry to .forceignore:

force-app/main/default/objects/Note_Relation__c/listViews/My_Notes.listView

This has no effect either. At this point, I'm stuck with a bunch of config changes in a scratch org that I cannot pull. I can find no references to this error message with scratch orgs. Has anyone seen this issue?

Edit to clarify: I tried the .forceignore line based on what I think the file name should be; I have no force-app/main/default/objects/Note_Relation__c/listViews directory locally.

Edit 2: Workaround: I found a workaround that doesn't make sense to me, but it works. I'm not adding it as an answer yet because I'm not sure what's happening. The workaround is to add the following line to .forceignore

Note_Relation__c.My_Notes

Even though this isn't a DX filepath, it's the name from the error message, and it seems to work.

Best Answer

Your workaround is spot on. We had quite similar issue with pull as mentioned in this question.

Also the documentation for .forceignore seems to be updated (or I may not have noticed it earlier), which says-

To exclude the same metadata in your local DX project (file system) and in a scratch org, create two entries to cover source:status, source:push, and source:pull.

For example, if you have a custom profile called Marketing Profile, include these two entries in .forceignore:

  • force-app/main/default/profiles/Marketing Profile.profile-meta.xml (ignores it during source:push or source:status)
  • Marketing Profile.profile (ignores it during source:pull or source:status)

tl;dr: Use absolute path of directory from force-app to the file to ignore for push and relative path to ignore for pull.