amtrack / sfdx-plugin-source-read

sfdx plugin to read Metadata via CRUD Metadata API
36 stars 4 forks source link

Error reading profile when Admin.profile-meta.xml file is missing #92

Closed Alfystar closed 4 months ago

Alfystar commented 4 months ago

Problem Description: When running the command sf force source read -m "Profile:Admin" without the presence of the src/main/default/profiles/Admin.profile-meta.xml file, the command executes without errors but does not save any information.

Steps to Reproduce:

  1. Ensure that the file src/main/default/profiles/Admin.profile-meta.xml does not exist.
  2. Execute the command sf force source read -m "Profile:Admin".
  3. Notice that the command does not return any errors but produces no output.

Expected Behavior: The command should either report an error indicating that the specified file is missing or automatically create the missing file.

Actual Behavior: The command runs without errors but does not save any output, even when the file is missing.

Temporary Workaround: Manually create an empty file named src/main/default/profiles/Admin.profile-meta.xml before running the command.

amtrack commented 4 months ago

@Alfystar I cannot reproduce this.

Could you please try the following?

$ sf project generate -n source-read-example-project --template empty
target dir = /Users/john.doe/Downloads
   create source-read-example-project/config/project-scratch-def.json
   create source-read-example-project/README.md
   create source-read-example-project/sfdx-project.json
   create source-read-example-project/.forceignore
$ cd source-read-example-project
$ sf force source read -m Profile:Admin --target-org the-target-org-you-want-to-retrieve-from
reading Profile:Admin ...
$ find force-app
force-app
force-app/main
force-app/main/default
force-app/main/default/lwc
force-app/main/default/profiles
force-app/main/default/profiles/Admin.profile-meta.xml
force-app/main/default/aura
$ wc -l force-app/main/default/profiles/Admin.profile-meta.xml
   30684 force-app/main/default/profiles/Admin.profile-meta.xml

Note: Typically force-app is the default package directory per sfdx-project.json. Would you mind sharing your sfdx-project.json?

Alfystar commented 4 months ago

Introduction, this morning I updated sf-cli to version 2.41.8 and started specifying the ORG target, and the problems disappeared.

Below I show you the logs with the updated version, although, this being the case, I believe that the issue can be closed for now

About the sfdx-project.json :

{
    "packageDirectories": [
      {
        "path": "src",
        "default": true
      }
    ],
    "name": "CRMT",
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "56.0"
  }

and from what I see, your tool was able to find the empty files and insert the read information into them.

I also followed your commands with both a classic repository, and using src, surprisingly, on the template repository, both work!

Test project with force-app

9:51:22 ~/testProfileIssue
└─▶ $ sf project generate -n source-read-example-project --template empty
target dir = /Users/ea_enel/testProfileIssue
   create source-read-example-project/config/project-scratch-def.json
   create source-read-example-project/README.md
   create source-read-example-project/sfdx-project.json
   create source-read-example-project/.forceignore

9:51:31 ~/testProfileIssue
└─▶ $ cd source-read-example-project 
9:51:39 ~/testProfileIssue/source-read-example-project
└─▶ $ tree
.
├── README.md
├── config
│   └── project-scratch-def.json
├── force-app
│   └── main
│       └── default
│           ├── aura
│           └── lwc
└── sfdx-project.json

7 directories, 3 files
9:51:49 ~/testProfileIssue/source-read-example-project
└─▶ $ cat sfdx-project.json         
{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "name": "source-read-example-project",
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "59.0"
}
9:52:03 ~/testProfileIssue/source-read-example-project
└─▶ $ sf force source read -m Profile:Admin --target-org DevInt_RM                               
reading Profile:Admin ...
(node:5387) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
9:52:53 ~/testProfileIssue/source-read-example-project
└─▶ $ tree
.
├── README.md
├── config
│   └── project-scratch-def.json
├── force-app
│   └── main
│       └── default
│           ├── aura
│           ├── lwc
│           └── profiles
│               └── Admin.profile-meta.xml
└── sfdx-project.json

8 directories, 4 files
9:53:03 ~/testProfileIssue/source-read-example-project
└─▶ $ wc -l force-app/main/default/profiles/Admin.profile-meta.xml 
  173823 force-app/main/default/profiles/Admin.profile-meta.xml
9:53:26 ~/testProfileIssue/source-read-example-project

Test project with src

9:54:54 ~/testProfileIssue
└─▶ $ sf project generate -n source-read-example-project_src --template empty
target dir = /Users/ea_enel/testProfileIssue
   create source-read-example-project_src/config/project-scratch-def.json
   create source-read-example-project_src/README.md
   create source-read-example-project_src/sfdx-project.json
   create source-read-example-project_src/.forceignore

9:55:08 ~/testProfileIssue
└─▶ $ cd source-read-example-project_src 
9:55:13 ~/testProfileIssue/source-read-example-project_src
9:55:15 ~/testProfileIssue/source-read-example-project_src
└─▶ $ mv force-app src                                                 
9:55:25 ~/testProfileIssue/source-read-example-project_src
└─▶ $ nano sfdx-project.json 
9:55:51 ~/testProfileIssue/source-read-example-project_src
└─▶ $ cat sfdx-project.json
{
  "packageDirectories": [
    {
      "path": "src",
      "default": true
    }
  ],
  "name": "source-read-example-project_src",
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "59.0"
}
9:56:03 ~/testProfileIssue/source-read-example-project_src
└─▶ $ tree                                                                  
.
├── README.md
├── config
│   └── project-scratch-def.json
├── sfdx-project.json
└── src
    └── main
        └── default
            ├── aura
            └── lwc

7 directories, 3 files
9:56:16 ~/testProfileIssue/source-read-example-project_src
└─▶ $ sf force source read -m Profile:Admin --target-org DevInt_RM           
reading Profile:Admin ...
(node:5731) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
9:56:50 ~/testProfileIssue/source-read-example-project_src
└─▶ $ tree
.
├── README.md
├── config
│   └── project-scratch-def.json
├── sfdx-project.json
└── src
    └── main
        └── default
            ├── aura
            ├── lwc
            └── profiles
                └── Admin.profile-meta.xml

8 directories, 4 files
9:57:21 ~/testProfileIssue/source-read-example-project_src
└─▶ $ wc -l src/main/default/profiles/Admin.profile-meta.xml
  173823 src/main/default/profiles/Admin.profile-meta.xml