I'm building a DX project now, and every time I try to push some fields, force:source:push
fails to recognize that the fields are an addition. I've tried deleting the source files, pushing, and then adding it back, editing properties in it, as well as creating a new artifact folder, putting the files in there, pushing, then moving it back to where I want it. Each time, the net result is that my scratch org ends up without the field in play, yet I can't get the field to push. Is there some file I can modify, or command argument, that will allow me to force this field to be pushed correctly? Even better, is there a way to force a recalculation of the artifacts so that I can get everything back in sync, since I don't even know what's missing from my org at this point? I have approximately 24,000 files to go through, so manual checking is a futile effort at best.
Additional Info
When this bug occurs, force:source:status
does not show that the file is created or modified, even after modifying the attributes of the field or moving it to a new file path then moving it back.
Editing .sfdx/orgs/<username>/sourcePathInfos.json
to modify the file attributes or remove the entry completely have no effect on resolving this bug.
I have had some luck deleting the contents of .sfdx/orgs/
, but then I typically end up with lots of errors about duplicate relationship names and lots of other errors.
What's really odd about it is that sometimes, I can add another file, since I'm spoonfeeding DX about 10-20 files at a time between each push, and the previously bugged out fields will show that they were added, but logging in to the scratch org, they still don't exist. At that point, they won't push again.
Ultimately, this question is to try and find the most foolproof, easiest way to resync the file system with the scratch org.
Demo Repo that demonstrates the problem. Readme includes instructions, but basically involves doing something like this:
$ git clone https://https://github.com/brianmfear/demo-repo.git
$ cd demo-repo
$ sfdx force:org:create -f config/project-scratch-def.json -a demo-repo -v DevHub
$ sfdx force:source:push
At this point, you'll see the following output:
STATE FULL NAME TYPE PROJECT PATH
───── ──────────────────────── ─────────── ─────────────────────────────────────────────────────────────────────────────
Add Account.Invalid_Field__c CustomField force-app\main\default\objects\Account\fields\Invalid_Field__c.field-meta.xml
Add Account.Valid_Field__c CustomField force-app\main\default\objects\Account\fields\Valid_Field__c.field-meta.xml
=== Push Errors
PROJECT PATH ERROR
───────────────────────────────────────────────────────────────────────────── ─────────────────────────────────────────────────────────────
force-app\main\default\objects\Account\fields\Invalid_Field__c.field-meta.xml Field Missing_Field__c does not exist. Check spelling. (3:13)
So, to fix it, let's say we delete Invalid_Field__c
:
$ rm force-app/main/default/Account/fields/Invalid_Field__c.field-meta.xml
Then try to push again:
$ sfdx force:source:push -u demo-repo
=== Pushed Source
STATE FULL NAME TYPE PROJECT PATH
─────── ──────────────────────── ─────────── ─────────────────────────────────────────────────────────────────────────────
Deleted Account.Invalid_Field__c CustomField force-app\main\default\objects\Account\fields\Invalid_Field__c.field-meta.xml
Note that the invalid field was deleted (but erroneously not marked as a local deletion, because it doesn't exist on the server), and the other remaining field doesn't exist.
Now, you need to clear the cache to fix it...
$ rm -r .sfdx/orgs/*
$ sfdx force:source:push -u demo-repo
=== Pushed Source
STATE FULL NAME TYPE PROJECT PATH
───── ────────────────────── ─────────── ───────────────────────────────────────────────────────────────────────────
Add Account.Valid_Field__c CustomField force-app\main\default\objects\Account\fields\Valid_Field__c.field-meta.xml