forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
494 stars 78 forks source link

moving a created field does not work (it tries to delete/insert) even when sf_beta_track_file_moves is set to true #3071

Open defabien opened 1 month ago

defabien commented 1 month ago

Expected result

when moving a field from one place to another, I expect tracking deploy to to something close to a noop

Actual result

when moving a field from one place to another, it tries to delete the field and insert it, resulting in errors when the field is being used

System Information

CLI:
@salesforce/cli/2.62.6 darwin-arm64 node-v20.17.0

Plugin Version:
@oclif/plugin-autocomplete 3.2.5 (core)
@oclif/plugin-commands 4.1.3 (core)
@oclif/plugin-help 6.2.14 (core)
@oclif/plugin-not-found 3.2.22 (core)
@oclif/plugin-plugins 5.4.14 (core)
@oclif/plugin-search 1.2.11 (core)
@oclif/plugin-update 4.6.3 (core)
@oclif/plugin-version 2.2.14 (core)
@oclif/plugin-warn-if-update-available 3.1.18 (core)
@oclif/plugin-which 3.2.15 (core)
@salesforce/cli 2.62.6 (core)
apex 3.5.1 (core)
api 1.3.1 (core)
auth 3.6.65 (core)
data 3.7.0 (core)
deploy-retrieve 3.12.17 (core)
info 3.4.9 (core)
limits 3.3.32 (core)
marketplace 1.2.26 (core)
org 4.6.0 (core)
packaging 2.8.11 (core)
schema 3.3.34 (core)
settings 2.3.23 (core)
signups 2.5.21 (user)
sobject 1.4.41 (core)
source 3.5.21 (core)
telemetry 3.6.15 (core)
templates 56.3.22 (core)
trust 3.7.33 (core)
user 3.5.32 (core)
SF ENV. VARS.
SF_BINPATH,/Users/fabien/.local/share/sf/client/bin/sf
SF_BETA_TRACK_FILE_MOVES,true
SF_AUTOUPDATE_DISABLE,true
SF_DISABLE_AUTOUPDATE,true
SF_UPDATE_INSTRUCTIONS,Use "npm update --global @salesforce/cli" to update npm-based installations.
Windows: false
Shell: zsh
Channel: stable

Diagnostics

:white_check_mark: pass - salesforcedx plugin isn’t installed :white_check_mark: pass - you don't have any linked plugins :white_check_mark: pass - [@salesforce/plugin-trust] can ping: https://registry.npmjs.org :white_check_mark: pass - [@salesforce/plugin-trust] can ping: https://registry.yarnpkg.com :white_check_mark: pass - [@salesforce/plugin-trust] can ping: https://registry.npmjs.org/ :white_check_mark: pass - using latest or latest-rc CLI version :white_check_mark: pass - [@salesforce/plugin-deploy-retrieve] sourceApiVersion matches apiVersion :x: warn - [@salesforce/plugin-deploy-retrieve] sourceApiVersion matches default target org max apiVersion :white_check_mark: pass - can access: https://test.salesforce.com :white_check_mark: pass - can access: https://appexchange.salesforce.com/services/data :white_check_mark: pass - [@salesforce/plugin-auth] CLI supports v2 crypto :white_check_mark: pass - can access: https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-win32-x64-buildmanifest

github-actions[bot] commented 1 month ago

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

iowillhoit commented 1 month ago

Hey @defabien, I don't know exactly what you are trying to do based on the info you provided, but I am pretty sure this is working as designed.

Are you moving a custom field from one Object to another Object?

If you are moving a child type, the Parent has to have the same metadata type and Name. Otherwise it needs to deleted and added. If you happen to be moving from a child type from one Project directory to another and the Parent name and type are the same, it will properly track (commit to local source tracking) the move.

If that is not what you are doing, I need exact steps to replicate your findings. Thanks!

defabien commented 1 month ago

Hi @iowillhoit,

Thank you for your time!

To clarify; I'm not moving a field from one object to another, in that case I would of course understand the behavior.

The steps I can take to reproduce;

  1. sf ui: create an object TestObject__c
  2. sf cli: retrieve
  3. ide: TestObject__c appears in bar/main/default/objects (in which bar is the default project folder)
  4. ide: move TestObject__c folder to package folder foo/objects
  5. sf ui: create a field TestObjectc.TestFieldc
  6. sf cli: retrieve
  7. ide: TestFieldc.field-meta.xml appears in bar/main/default/objects/TestObjectc/fields
  8. ide: move TestFieldc.field-meta.xml to foo/objects/TestObjectc/fields
  9. sf cli: deploy
  10. sf cli: does delete and create of TestField__c which often causes issues for obvious reasons. (used in class, etc, ...)
iowillhoit commented 3 weeks ago

Hey @defabien, I am not seeing a "delete" when moving fields as you described. Here is a screencast, let me know if I missed something!

https://github.com/user-attachments/assets/0a815bac-447f-4d5c-a604-6d0f153950e9

iowillhoit commented 1 week ago

@defabien Do you see anything that I missed in my screencast?