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

JSON response truncated #3134

Open
mmakwanaCertinia opened this issue Dec 4, 2024 · 7 comments
Open

JSON response truncated #3134

mmakwanaCertinia opened this issue Dec 4, 2024 · 7 comments
Labels
more information required Issue requires more information or a response from the customer stale validated Version information for this issue has been validated

Comments

@mmakwanaCertinia
Copy link

Summary

When processing the JSON output of a SF command we are unable to as the response gets truncated and ends up not being valid JSON. Specifically when calling the command: sf apex run -o ${USERNAME} -f ${file} --json we receive a response like:

{
  "name": "executeRuntimeFailure",
  "message": "Execution failed at this code:\n\nSystem.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Test Field is required: [Test_Field__c]",
  "exitCode": 1,
  "context": "Run",
  "data": {
    "success": false,
    "compiled": true,
    "compileProblem": "",
    "exceptionMessage": "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Test Field is required: [Test_Field__c]",
    "exceptionStackTrace": "Class.test.SystemTest001.createObject_run: line 57, column 1\nAnonymousBlock: line 1, column 1\nAnonymousBlock: line 1, column 1",
    "line": "57",
    "column": "1",
    "logs": "61.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,NONE;DB,NONE;NBA,INFO;SYSTEM,DEBUG;VALIDATION,NONE;VISUALFORCE,NONE;WAVE,INFO;WORKFLOW,NONE\nExecute Anonymous: SystemTest001.createObject_run();\n13:04:28.36 (36955400)|EXECUTION_STARTED\n13:04:28.36 (36971476)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex\n13:04:28.36 (37472375)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (65265458)|CODE_UNIT_STARTED|[EXTERNAL]|01qDL000002EXX9|test.Object1Trigger on Object1 Trigger event BeforeInsert|__sfdc_trigger/test/Object1Trigger\n13:04:28.36 (93958771)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (94526230)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (94551438)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (94934027)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (95056716)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (95154977)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (95220628)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (95299480)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (95357573)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (95429285)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (95485816)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (95554598)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (95609711)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (95685178)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (95741858)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (95809608)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (96092750)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (96183453)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (96267156)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (96335548)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (120976215)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (120991468)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (121042162)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (121061703)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (121130097)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (121362753)|SYSTEM_MODE_ENTER|true\n13:04:28.36 (121376258)|SYSTEM_MODE_EXIT|true\n13:04:28.36 (121382100)|SYSTEM_MODE_ENTER|true\n13:04:28.36 (121386666)|SYSTEM_MODE_EXIT|true\n13:04:28.36 (121401654)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (130456973)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (130471349)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (130489509)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (130506380)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (131394593)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (131453324)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (131537394)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (132705805)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (137435557)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (137448461)|SYSTEM_MODE_EXIT|false\n13:04:28.137 (137468676)|CUMULATIVE_LIMIT_USAGE\n13:04:28.137 (137468676)|LIMIT_USAGE_FOR_NS|(default)|\n  Number of SOQL queries: 0 out of 100\n  Number of query rows: 0 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 0 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 0 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n13:04:28.137 (137468676)|LIMIT_USAGE_FOR_NS|integration_package|\n  Number of SOQL queries: 1 out of 100\n  Number of query rows: 0 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 0 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 0 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n13:04:28.137 (137468676)|LIMIT_USAGE_FOR_NS|test|\n  Number of SOQL queries: 2 out of 100\n  Number of query rows: 3 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 1 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 1 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n13:04:28.137 (137468676)|CUMULATIVE_LIMIT_USAGE_END\n\n13:04:28.36 (137887965)|CODE_UNIT_FINISHED|test.Object1Trigger on Object1 Trigger event BeforeInsert|__sfdc_trigger/test/Object1Trigger\n13:04:28.36 (140144734)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:Object1:new\n13:04:28.36 (140398002)|CODE_UNIT_FINISHED|Validation:Object1:new\n13:04:28.36 (168500671)|CODE_UNIT_STARTED|[EXTERNAL]|01qDL000002EXX9|test.Object1Trigger on Object1 Trigger event AfterInsert|__sfdc_trigger/test/Object1Trigger\n13:04:28.36 (170026864)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (170060638)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (170435180)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (170443254)|SYSTEM_MODE_EXIT|false\n13:04:28.170 (170461204)|CUMULATIVE_LIMIT_USAGE\n13:04:28.170 (170461204)|LIMIT_USAGE_FOR_NS|(default)|\n  Number of SOQL queries: 0 out of 100\n  Number of query rows: 0 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 0 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 0 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n13:04:28.170 (170461204)|LIMIT_USAGE_FOR_NS|integration_package|\n  Number of SOQL queries: 1 out of 100\n  Number of query rows: 0 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 0 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 0 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n13:04:28.170 (170461204)|LIMIT_USAGE_FOR_NS|test|\n  Number of SOQL queries: 2 out of 100\n  Number of query rows: 3 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 1 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 1 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n13:04:28.170 (170461204)|CUMULATIVE_LIMIT_USAGE_END\n\n13:04:28.36 (170639383)|CODE_UNIT_FINISHED|test.Object1Trigger on Object1 Trigger event AfterInsert|__sfdc_trigger/test/Object1Trigger\n13:04:28.36 (182088914)|CODE_UNIT_STARTED|[EXTERNAL]|01qDL000002EXWY|test.Object2Trigger on Object2 Trigger event BeforeInsert|__sfdc_trigger/test/Object2Trigger\n13:04:28.36 (218220912)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (218263019)|SYSTEM_MODE_EXIT|false\n13:04:28.36 (218449175)|SYSTEM_MODE_ENTER|false\n13:04:28.36 (220015671)|SYSTEM_MODE_ENTER|true

Steps To Reproduce

Run sf apex run -o ${USERNAME} -f ${file} --json.

Expected result

Correctly formed JSON returned.

Actual result

Malformed JSON returned

System Information

Terminal = zsh

{
  "architecture": "darwin-x64",
  "cliVersion": "@salesforce/cli/2.63.8",
  "nodeVersion": "node-v20.12.2",
  "osVersion": "Darwin 23.6.0",
  "rootPath": "{MY_PATH}/node_modules/.pnpm/@[email protected]/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.6 (core)",
    "@oclif/plugin-commands 4.1.3 (core)",
    "@oclif/plugin-help 6.2.15 (core)",
    "@oclif/plugin-not-found 3.2.22 (core)",
    "@oclif/plugin-plugins 5.4.15 (core)",
    "@oclif/plugin-search 1.2.12 (core)",
    "@oclif/plugin-update 4.6.4 (core)",
    "@oclif/plugin-version 2.2.15 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.19 (core)",
    "@oclif/plugin-which 3.2.16 (core)",
    "@salesforce/cli 2.63.8 (core)",
    "apex 3.5.4 (core)",
    "api 1.3.1 (core)",
    "auth 3.6.68 (core)",
    "data 3.7.1 (core)",
    "deploy-retrieve 3.15.3 (core)",
    "info 3.4.12 (core)",
    "limits 3.3.33 (core)",
    "marketplace 1.2.26 (core)",
    "org 4.7.0 (core)",
    "packaging 2.8.12 (core)",
    "schema 3.3.36 (core)",
    "settings 2.3.24 (core)",
    "sobject 1.4.42 (core)",
    "source 3.5.21 (core)",
    "telemetry 3.6.16 (core)",
    "templates 56.3.24 (core)",
    "trust 3.7.34 (core)",
    "user 3.5.33 (core)"
  ]
}

Note: Tested on the latest SF CLI version and resulted in the same outcome.

@mmakwanaCertinia mmakwanaCertinia added the investigating We're actively investigating this issue label Dec 4, 2024
Copy link

github-actions bot commented Dec 4, 2024

Hello @mmakwanaCertinia 👋 None of the versions of sf you shared match the latest release.

Shared: 2.63.8
Latest: 2.67.7

Update to the latest version of Salesforce CLI (docs) and confirm that you're still seeing your issue.
You can also try the rc and nightly releases! (docs)

After updating, share the full output of sf version --verbose --json

@github-actions github-actions bot added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Dec 4, 2024
Copy link

github-actions bot commented Dec 4, 2024

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.

@mmakwanaCertinia
Copy link
Author

Tested on the latest SF CLI version (2.67.7) and it resulted in the same outcome.

@mmakwanaCertinia
Copy link
Author

Updated SF output:

{
  "architecture": "darwin-x64",
  "cliVersion": "@salesforce/cli/2.67.7",
  "nodeVersion": "node-v20.12.2",
  "osVersion": "Darwin 23.6.0",
  "rootPath": "/Users/mmakwana/.nvm/versions/node/v20.12.2/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.8 (core)",
    "@oclif/plugin-commands 4.1.8 (core)",
    "@oclif/plugin-help 6.2.16 (core)",
    "@oclif/plugin-not-found 3.2.25 (core)",
    "@oclif/plugin-plugins 5.4.15 (core)",
    "@oclif/plugin-search 1.2.14 (core)",
    "@oclif/plugin-update 4.6.10 (core)",
    "@oclif/plugin-version 2.2.15 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.21 (core)",
    "@oclif/plugin-which 3.2.17 (core)",
    "@salesforce/cli 2.67.7 (core)",
    "apex 3.6.2 (core)",
    "api 1.3.2 (core)",
    "auth 3.6.73 (core)",
    "data 3.11.3 (core)",
    "deploy-retrieve 3.15.11 (core)",
    "info 3.4.18 (core)",
    "limits 3.3.39 (core)",
    "marketplace 1.3.4 (core)",
    "org 5.1.4 (core)",
    "packaging 2.9.0 (core)",
    "schema 3.3.40 (core)",
    "settings 2.4.4 (core)",
    "sobject 1.4.45 (core)",
    "telemetry 3.6.20 (core)",
    "templates 56.3.29 (core)",
    "trust 3.7.41 (core)",
    "user 3.6.2 (core)"
  ]
}

Confirmed behaviour is still present

@github-actions github-actions bot added validated Version information for this issue has been validated investigating We're actively investigating this issue and removed more information required Issue requires more information or a response from the customer labels Dec 4, 2024
@mdonnalley
Copy link
Contributor

@mmakwanaCertinia I'm not able to reproduce this using the following:

test.apex

throw new DmlException('Insert failed');

sf apex run --file test.apex --json

{
  "name": "executeRuntimeFailure",
  "message": "Execution failed at this code:\n\nSystem.DmlException: Insert failed",
  "exitCode": 1,
  "context": "Run",
  "data": {
    "success": false,
    "compiled": true,
    "compileProblem": "",
    "exceptionMessage": "System.DmlException: Insert failed",
    "exceptionStackTrace": "AnonymousBlock: line 1, column 1",
    "line": "1",
    "column": "1",
    "logs": "62.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO\nExecute Anonymous: throw new DmlException('Insert failed');\n09:20:51.21 (21118024)|USER_INFO|[EXTERNAL]|005O800000Dkz4Q|[email protected]|(GMT-08:00) Pacific Standard Time (America/Los_Angeles)|GMT-08:00\n09:20:51.21 (21143028)|EXECUTION_STARTED\n09:20:51.21 (21150308)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex\n09:20:51.21 (21569163)|FATAL_ERROR|System.DmlException: Insert failed\n\nAnonymousBlock: line 1, column 1\n09:20:51.21 (21599783)|CUMULATIVE_LIMIT_USAGE\n09:20:51.21 (21599783)|LIMIT_USAGE_FOR_NS|(default)|\n  Number of SOQL queries: 0 out of 100\n  Number of query rows: 0 out of 50000\n  Number of SOSL queries: 0 out of 20\n  Number of DML statements: 0 out of 150\n  Number of Publish Immediate DML: 0 out of 150\n  Number of DML rows: 0 out of 10000\n  Maximum CPU time: 0 out of 10000\n  Maximum heap size: 0 out of 6000000\n  Number of callouts: 0 out of 100\n  Number of Email Invocations: 0 out of 10\n  Number of future calls: 0 out of 50\n  Number of queueable jobs added to the queue: 0 out of 50\n  Number of Mobile Apex push calls: 0 out of 10\n\n09:20:51.21 (21599783)|CUMULATIVE_LIMIT_USAGE_END\n\n09:20:51.21 (21623798)|CODE_UNIT_FINISHED|execute_anonymous_apex\n09:20:51.21 (21630501)|EXECUTION_FINISHED\n"
  },
  "stack": "executeRuntimeFailure: Execution failed at this code:\n\nSystem.DmlException: Insert failed\n    at SfCommandError.from (file:///Users/mdonnalley/.volta/tools/image/packages/@salesforce/cli/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:39:16)\n    at Run.catch (file:///Users/mdonnalley/.volta/tools/image/packages/@salesforce/cli/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:316:47)\n    at Run._run (/Users/mdonnalley/.volta/tools/image/packages/@salesforce/cli/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:306:29)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Config.runCommand (/Users/mdonnalley/.volta/tools/image/packages/@salesforce/cli/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:425:25)\n    at async run (/Users/mdonnalley/.volta/tools/image/packages/@salesforce/cli/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:95:16)\n    at async file:///Users/mdonnalley/.volta/tools/image/packages/@salesforce/cli/lib/node_modules/@salesforce/cli/bin/run.js:15:1",
  "cause": "undefined",
  "warnings": [],
  "code": "executeRuntimeFailure",
  "status": 1,
  "commandName": "Run"
}

Are you able to share a repo that replicates the issue? Thanks!

@mdonnalley mdonnalley added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Dec 4, 2024
@ntaylorcertinia
Copy link

ntaylorcertinia commented Dec 6, 2024

@mdonnalley hey, I work with @mmakwanaCertinia and he is off ATM, will see if I can get a repo together for you or at least some repro conditions. My suspicion though is that this error will depend on the response which will be determined by the size of the log file that gets returned.

Just throwing an exception likely generates a fairly short log so it might need to do something a little more

Copy link

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

@github-actions github-actions bot added the stale label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more information required Issue requires more information or a response from the customer stale validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

3 participants