Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sm/error json #450

Merged
merged 9 commits into from
Mar 17, 2022
Merged

Sm/error json #450

merged 9 commits into from
Mar 17, 2022

Conversation

mshanemc
Copy link
Contributor

@mshanemc mshanemc commented Mar 11, 2022

What does this PR do?

error structure for push/pull matches toolbelt (well, mostly).
intentional exceptions

  1. commandName changes
  2. use absolute rather than relative paths (match deploy, retrieve, etc)

What issues does this PR fix or reference?

@W-10830392@
@W-10809263@
forcedotcom/cli#1431

@iowillhoit
Copy link
Contributor

QA Notes

🟡 push and pull are not listed in the topic help when running sfdx force:source

sfdx force:source
sync your project with your orgs

USAGE
    $ sfdx force:source:COMMAND

TOPICS
    force:source:beta      new versions of source tracking commands
    force:source:deploy    interact with an active deploy request
    force:source:ignored   check your local project package directories for forceignored files
    force:source:legacy    backwards compatible support for the original version of tracking commands. Use only while transitioning to the new commands
    force:source:manifest  create a manifest to use in a deploy/retrieve

COMMANDS
    force:source:convert   convert source into Metadata API format
    force:source:delete    delete source from your project and from a non-source-tracked org
    force:source:deploy    deploy source to an org
    force:source:open      edit a Lightning Page with Lightning App Builder
    force:source:retrieve  retrieve source from an org

🔴 Contract changed on pull with no changes

toolbelt

{
    "status": 0,
    "result": {
        "pulledSource": []
    }
}

plugin-source

{
    "status": 0,
    "result": []
}

🟢 Absolute paths are being used as described

"/Users/ewillhoit/dev/sandbox/org--dreamhouse-plugin-source/force-app/main/default/applications/Dreamhouse.app-meta.xml"

🟡 pushedSource[].state is different when pushing (Add vs Created)

toolbelt

  • Uses "state": "Add",

plugin-source

  • Uses "state": "Created",

🟡 pushedSource[].fullname is occasionally different. toolbelt uses dir/file format. plugin-source uses dir. Example using dreamhouse:

toolbelt

{
    "state": "Add",
    "fullName": "pageTemplate_2_7_3/pageTemplate_2_7_3.cmp",
    "type": "AuraDefinitionBundle",
    "filePath": "force-app/main/default/aura/pageTemplate_2_7_3/pageTemplate_2_7_3.cmp"
}

plugin-source

{
    "state": "Created",
    "fullName": "pageTemplate_2_7_3",
    "type": "AuraDefinitionBundle",
    "filePath": "/Users/ewillhoit/dev/sandbox/org--dreamhouse-plugin-source/force-app/main/default/aura/pageTemplate_2_7_3/pageTemplate_2_7_3.cmp"
}

🟢 Contract on push the same when there is nothing to push

🔴 Contract changed on pull!

toolbelt

  • result is an object with pulledSource array
  • "Layout" was pulled
{
    "status": 0,
    "result": {
    "pulledSource": [
        {
            "state": "Add",
            "fullName": "CO_Toolbelt__c",
            "type": "CustomObject",
            "filePath": "force-app/main/default/objects/CO_Toolbelt__c/CO_Toolbelt__c.object-meta.xml"
        },
        {
            "state": "Add",
            "fullName": "CO_Toolbelt__c-CO_Toolbelt Layout",
            "type": "Layout",
            "filePath": "force-app/main/default/layouts/CO_Toolbelt__c-CO_Toolbelt Layout.layout-meta.xml"
        }
    ]
    }
}

plugin-source

  • result is an array, no pulledSource array.
  • "Layout" not pulled? 🤔
{
    "status": 0,
    "result": [
        {
            "state": "Created",
            "fullName": "CO_Plugin_Source__c",
            "type": "CustomObject",
            "filePath": "/Users/ewillhoit/dev/sandbox/org--dreamhouse-plugin-source/force-app/main/default/objects/CO_Plugin_Source__c/CO_Plugin_Source__c.object-meta.xml"
        }
    ]
}

🟢 Contract the same on push for a locally created object

🔴 Contract different on push of invalid Custom Object

toolbelt

{
    "status": 1,
    "result": [
    {
        "error": "Must specify a non-empty label for the CustomObject",
        "fullName": "CO_Toolbelt_local__c",
        "type": "CustomObject",
        "filePath": "force-app/main/default/objects/CO_Toolbelt_local__c/CO_Toolbelt_local__c.object-meta.xml",
        "problemType": "Error"
    }
    ],
    "name": "DeployFailed",
    "message": "Push failed.",
    "exitCode": 1,
    "actions": [],
    "commandName": "SourcePushCommand",
    "data": [
    {
        "error": "Must specify a non-empty label for the CustomObject",
        "fullName": "CO_Toolbelt_local__c",
        "type": "CustomObject",
        "filePath": "force-app/main/default/objects/CO_Toolbelt_local__c/CO_Toolbelt_local__c.object-meta.xml",
        "problemType": "Error"
    }
    ],
    "stack": "DeployFailed: Push failed.\n    at /Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/lib/source/sourceApiCommand.js:71:31\n    at async SourcePushCommand.execLegacyCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/ToolbeltCommand.js:149:29)\n    at async SourcePushCommand.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/commands/force/source/legacy/push.js:37:16)\n    at async SourcePushCommand._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@salesforce/command/lib/sfdxCommand.js:81:40)\n    at async Config.runCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/config/lib/config.js:173:24)\n    at async SfdxMain.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/main.js:27:9)\n    at async SfdxMain._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/command.js:43:20)\n    at async Object.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/dist/cli.js:162:47)",
    "warnings": []
}

plugin-source

  • No result array
  • No actions array
  • No data array
{
    "status": 1,
    "name": "TypeInferenceError",
    "message": "Unexpected child metadata [force-app/main/default/objects/CO_Plugin_Source_local_BAD__c/CO_Plugin_Source_local__c.object-meta.xml] found for parent type [CustomObject]",
    "exitCode": 1,
    "commandName": "Push",
    "stack": "TypeInferenceError: Unexpected child metadata [force-app/main/default/objects/CO_Plugin_Source_local_BAD__c/CO_Plugin_Source_local__c.object-meta.xml] found for parent type [CustomObject]\n    at DecomposedSourceAdapter.populate (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/adapters/decomposedSourceAdapter.ts:115:17)\n    at DecomposedSourceAdapter.getComponent (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/adapters/decomposedSourceAdapter.ts:70:17)\n    at MetadataResolver.resolveComponent (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:138:38)\n    at MetadataResolver.getComponentsFromPathRecursive (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:92:32)\n    at MetadataResolver.getComponentsFromPathRecursive (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:115:31)\n    at MetadataResolver.getComponentsFromPathRecursive (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:115:31)\n    at MetadataResolver.getComponentsFromPathRecursive (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:115:31)\n    at MetadataResolver.getComponentsFromPathRecursive (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:115:31)\n    at MetadataResolver.getComponentsFromPath (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/resolve/metadataResolver.ts:58:19)\n    at buildComponents (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/collections/componentSet.ts:137:42)\n    at Function.fromSource (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/node_modules/@salesforce/source-deploy-retrieve/src/collections/componentSet.ts:142:5)\n    at SourceTracking.populateFilePaths (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/lib/sourceTracking.js:569:88)\n    at SourceTracking.getChanges (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/lib/sourceTracking.js:198:29)\n    at async SourceTracking.getConflicts (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/source-tracking/lib/sourceTracking.js:393:31)\n    at async Object.trackingSetup (/Users/ewillhoit/dev/plugin-source/src/trackingFunctions.ts:60:26)\n    at async Push.prechecks (/Users/ewillhoit/dev/plugin-source/src/commands/force/source/beta/push.ts:36:25)\nOuter stack:\n    at Function.wrap (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/core/lib/sfdxError.js:171:27)\n    at Push.catch (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/command/lib/sfdxCommand.js:248:67)\n    at async Push._run (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/command/lib/sfdxCommand.js:85:13)\n    at async Config.runCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/config/lib/config.js:173:24)\n    at async SfdxMain.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/main.js:27:9)\n    at async SfdxMain._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/command.js:43:20)\n    at async Object.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/dist/cli.js:162:47)",
    "warnings": []
}

@iowillhoit
Copy link
Contributor

Only thing that I didn't test was a failure on pull. I am not sure how to get that to fail. Any ideas?

@mshanemc
Copy link
Contributor Author

mshanemc commented Mar 16, 2022

Only thing that I didn't test was a failure on pull. I am not sure how to get that to fail. Any ideas?

You can get an error from conflicts (change something remote and local and then try to pull)

@mshanemc
Copy link
Contributor Author

🔴 Contract different on push of invalid Custom Object
That's an error from SDR, which occurs locally instead of sending bad objects to the server and getting back its response. It's gonna be like other errors that happen outside of the deployment (ex: invalid flags, etc)

@mshanemc
Copy link
Contributor Author

mshanemc commented Mar 16, 2022

pushedSource[].fullname is occasionally different. toolbelt uses dir/file format. plugin-source uses dir.
state: Add vsCreate

Also coming from SDR/metadata api. Let's leave them so they're consistent with the other commands unless we hear otherwise.

@iowillhoit
Copy link
Contributor

Got pull errors. The top level keys are the same, but there are some differences. Could you look over the following and confirm we are ok with the variations?

toolbelt

{
  "status": 1,
  "result": [
    {
      "state": "Conflict",
      "fullName": "CP_Toolbelt_2__c",
      "type": "CustomObject",
      "filePath": "force-app/main/default/objects/CP_Toolbelt_2__c/CP_Toolbelt_2__c.object-meta.xml"
    }
  ],
  "name": "sourceConflictDetected",
  "message": "Source conflict(s) detected.",
  "exitCode": 1,
  "commandName": "SourcePullCommand",
  "data": [
    {
      "state": "Conflict",
      "fullName": "CP_Toolbelt_2__c",
      "type": "CustomObject",
      "filePath": "force-app/main/default/objects/CP_Toolbelt_2__c/CP_Toolbelt_2__c.object-meta.xml"
    }
  ],
  "stack": "sourceConflictDetected: Source conflict(s) detected.\n    at ALMError (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/lib/core/almError.js:42:19)\n    at /Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/lib/source/sourcePullCommand.js:45:31\n    at async SourcePullCommand.execLegacyCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/ToolbeltCommand.js:149:29)\n    at async SourcePullCommand._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@salesforce/command/lib/sfdxCommand.js:81:40)\n    at async Config.runCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/config/lib/config.js:173:24)\n    at async SfdxMain.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/main.js:27:9)\n    at async SfdxMain._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/command.js:43:20)\n    at async Object.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/dist/cli.js:162:47)\nOuter stack:\n    at Function.wrap (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/sfdxError.js:171:27)\n    at SourcePullCommand.catch (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/dist/ToolbeltCommand.js:253:46)\n    at async SourcePullCommand._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@salesforce/command/lib/sfdxCommand.js:85:13)\n    at async Config.runCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/config/lib/config.js:173:24)\n    at async SfdxMain.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/main.js:27:9)\n    at async SfdxMain._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/command.js:43:20)\n    at async Object.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/dist/cli.js:162:47)",
  "warnings": []
}

plugin-source

{
  "status": 1,
  "result": [
    {
      "type": "CustomObject",
      "name": "CO_Plugin_Source_2__c",
      "deleted": false,
      "origin": "remote",
      "modified": true,
      "filenames": [
        "force-app/main/default/objects/CO_Plugin_Source_2__c/CO_Plugin_Source_2__c.object-meta.xml"
      ]
    }
  ],
  "name": "SfdxError",
  "message": "We couldn't complete the operation due to conflicts. Verify that you want to keep the existing versions, then run the command again with the --forceoverwrite (-f) option.",
  "exitCode": 1,
  "commandName": "Pull",
  "data": [
    {
      "type": "CustomObject",
      "name": "CO_Plugin_Source_2__c",
      "deleted": false,
      "origin": "remote",
      "modified": true,
      "filenames": [
        "force-app/main/default/objects/CO_Plugin_Source_2__c/CO_Plugin_Source_2__c.object-meta.xml"
      ]
    }
  ],
  "stack": "SfdxError: We couldn't complete the operation due to conflicts. Verify that you want to keep the existing versions, then run the command again with the --forceoverwrite (-f) option.\n    at processConflicts (/Users/ewillhoit/dev/plugin-source/src/trackingFunctions.ts:119:17)\n    at Object.trackingSetup (/Users/ewillhoit/dev/plugin-source/src/trackingFunctions.ts:60:9)\n    at async Pull.preChecks (/Users/ewillhoit/dev/plugin-source/src/commands/force/source/beta/pull.ts:39:25)\n    at async Pull.run (/Users/ewillhoit/dev/plugin-source/src/commands/force/source/beta/pull.ts:25:9)\n    at async Pull._run (/Users/ewillhoit/dev/plugin-source/node_modules/@salesforce/command/lib/sfdxCommand.js:81:40)\n    at async Config.runCommand (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/config/lib/config.js:173:24)\n    at async SfdxMain.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/main.js:27:9)\n    at async SfdxMain._run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/command.js:43:20)\n    at async Object.run (/Users/ewillhoit/.nvm/versions/node/v14.17.5/lib/node_modules/sfdx-cli/dist/cli.js:162:47)",
  "warnings": []
}

@iowillhoit
Copy link
Contributor

Updated QA Notes

🟡 push and pull are not listed in the topic help when running sfdx force:source

NOTE: This will only be an issue while the two sources are in beta and legacy. This will not be a long term issue.

🟢 Resolved! 🔴 Contract changed on pull with no changes

🟢 Absolute paths are being used as described

🟡 pushedSource[].state is different when pushing (Add vs Created)

NOTE: Shane is confirming with Scott Wells

🟡 pushedSource[].fullname is occasionally different. toolbelt uses dir/file format. plugin-source uses dir. Example using dreamhouse:

NOTE FROM SHANE: This is coming from SDR/metadata API. Leave as is until we hear otherwise

🟢 Contract on push the same when there is nothing to push

🟡 RESOLVED (mostly) 🔴 Contract changed on pull!

NOTE: Contract is fixed. Layout is still not being pulled using plugin-source?

🟢 Contract the same on push for a locally created object

🟢 Working as designed 🔴 Contract different on push of invalid Custom Object

NOTE FROM SHANE: This error is coming from SDR locally

@iowillhoit
Copy link
Contributor

Awesome, the conflict output now matches! Although, I did just notice that result.filePath and data.filePath are not absolute paths in plugin-source in the pull conflict json.

Copy link
Contributor

@iowillhoit iowillhoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@mshanemc mshanemc merged commit 5f36a37 into main Mar 17, 2022
@mshanemc mshanemc deleted the sm/error-json branch March 17, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants