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

Cannot read properties of null (reading 'replace') when trying to retrieve Apex Test results #331

Open
Garnet-Merrill opened this issue Aug 29, 2023 · 4 comments

Comments

@Garnet-Merrill
Copy link

Garnet-Merrill commented Aug 29, 2023

Summary

I am running the following command to retrieve Apex test run results.
sf apex get test -o --test-run-id -d --code-coverage -r human

Expected result

This should produce 6 files in the specified directory

Actual result

I received the following error.
Error (1): Cannot read properties of null (reading 'replace')

This error only occurs if if use the -d flag to specify where to save the results. If I run without the -d and path, I will get data returned which I can redirect to a file.

I have a similar problem when I try to use the -d parameter in running the test, although the error is slightly different.
Error (1): Cannot read properties of undefined (reading 'Status')

Steps To Reproduce

I've updated the sf client to ensure I had the latest version. I've run this against different SalesForce Orgs and specified different directories to eliminate environmental issues. I've also run this from a Mac and Linux. Everything seems to run fine until I specify the directory output. (I've tried relative and full paths)

System Information

System Information

{
"versionDetail": {
"cliVersion": "@salesforce/cli/2.5.8",
"architecture": "linux-arm64",
"nodeVersion": "node-v20.5.0",
"osVersion": "Linux 5.15.49-linuxkit-pr",
"shell": "ash",
"rootPath": "/usr/local/lib/node_modules/@salesforce/cli",
"pluginVersions": [
"@oclif/plugin-autocomplete 2.3.6 (core)",
"@oclif/plugin-commands 2.2.22 (core)",
"@oclif/plugin-help 5.2.17 (core)",
"@oclif/plugin-not-found 2.3.37 (core)",
"@oclif/plugin-plugins 3.2.6 (core)",
"@oclif/plugin-search 0.0.22 (core)",
"@oclif/plugin-update 3.1.32 (core)",
"@oclif/plugin-version 1.3.8 (core)",
"@oclif/plugin-warn-if-update-available 2.0.48 (core)",
"@oclif/plugin-which 2.2.30 (core)",
"@salesforce/cli 2.5.8 (core)",
"apex 2.3.10 (core)",
"auth 2.8.12 (core)",
"data 2.5.6 (core)",
"deploy-retrieve 1.17.5 (core)",
"info 2.6.39 (core)",
"limits 2.3.30 (core)",
"login 1.2.26 (core)",
"org 2.10.0 (core)",
"schema 2.3.23 (core)",
"settings 1.4.25 (core)",
"sobject 0.2.4 (core)",
"source 2.10.31 (core)",
"telemetry 2.3.0 (core)",
"templates 55.5.10 (core)",
"trust 2.6.1 (core)",
"user 2.3.28 (core)"
]
},
"sfdxEnvVars": [],
"sfEnvVars": [
[
"SF_AUTOUPDATE_DISABLE",
"true"
],
[
"SF_DISABLE_AUTOUPDATE",
"true"
],
[
"SF_UPDATE_INSTRUCTIONS",
"Use "npm update --global @salesforce/cli" to update npm-based installations."
]
],
"cliConfig": {
"_base": "@oclif/[email protected]",
"debug": 0,
"topicSeparator": " ",
"warned": false,
"commandPermutations": {
"validPermutations": {}
},
"topicPermutations": {
"validPermutations": {}
},
"_commands": {},
"_topics": {},
"root": "/usr/local/lib/node_modules/@salesforce/cli",
"name": "@salesforce/cli",
"version": "2.5.8",
"channel": "stable",
"valid": true,
"arch": "arm64",
"platform": "linux",
"windows": false,
"bin": "sf",
"binAliases": [
"sfdx"
],
"nsisCustomization": "scripts/nsis.nsi",
"dirname": "sf",
"flexibleTaxonomy": true,
"userAgent": "@salesforce/cli/2.5.8 linux-arm64 node-v20.5.0",
"shell": "ash",
"home": "/root",
"cacheDir": "/root/.cache/sf",
"configDir": "/root/.config/sf",
"dataDir": "/root/.local/share/sf",
"errlog": "/root/.cache/sf/error.log",
"_commandIDs": [
"cmdt:generate:field",
"force:cmdt:field:create",
"cmdt:field:create",
"cmdt:generate:fromorg",
"force:cmdt:generate",
"cmdt:generate:object",
"force:cmdt:create",
"cmdt:create",
"cmdt:generate:record",
"force:cmdt:record:create",
"cmdt:record:create",
"cmdt:generate:records",
"force:cmdt:record:insert",
"cmdt:record:insert",
"community:create",
"force:community:create",
"community:list:template",
"force:community:template:list",
"community:publish",
"force:community:publish",
"deploy:functions",
"dev:audit:messages",
"dev:configure:repo",
"dev:configure:secrets",
"dev:convert:messages",
"dev:convert:script",
"dev:generate:command",
"dev:generate:flag",
"dev:generate:library",
"dev:generate:plugin",
"plugins:generate",
"env:compute:collaborator:add",
"env:create:compute",
"env:delete",
"env:display",
"env:list",
"env:log",
"env:log:tail",
"env:logdrain:add",
"env:logdrain:list",
"env:logdrain:remove",
"env:open",
"env:var:get",
"env:var:list",
"env:var:set",
"env:var:unset",
"force:lightning:lwc:test:create",
"force:lightning:lwc:test:run",
"force:lightning:lwc:test:setup",
"generate:function",
"login:functions",
"login:functions:jwt",
"logout:functions",
"org:create:shape",
"force:org:shape:create",
"org:create:snapshot",
"force:org:snapshot:create",
"org:delete:shape",
"force:org:shape:delete",
"org:delete:snapshot",
"force:org:snapshot:delete",
"org:get:snapshot",
"force:org:snapshot:get",
"org:list:shape",
"force:org:shape:list",
"org:list:snapshot",
"force:org:snapshot:list",
"package:convert",
"force:package:convert",
"package:create",
"force:package:create",
"package:delete",
"force:package:delete",
"package:install",
"force:package:install",
"package:install:report",
"force:package:install:report",
"package:installed:list",
"force:package:installed:list",
"package:list",
"force:package:list",
"package:uninstall",
"force:package:uninstall",
"package:uninstall:report",
"force:package:uninstall:report",
"package:update",
"force:package:update",
"package:version:create",
"force:package:version:create",
"package:version:create:list",
"force:package:version:create:list",
"package:version:create:report",
"force:package:version:create:report",
"package:version:delete",
"force:package:version:delete",
"package:version:displayancestry",
"force:package:version:displayancestry",
"package:version:list",
"force:package:version:list",
"package:version:promote",
"force:package:version:promote",
"package:version:report",
"force:package:version:report",
"package:version:retrieve",
"package:version:update",
"force:package:version:update",
"package1:version:create",
"force:package1:version:create",
"package1:version:create:get",
"force:package1:version:create:get",
"package1:version:display",
"force:package1:version:display",
"package1:version:list",
"force:package1:version:list",
"run:function",
"run:function:start",
"run:function:start:container",
"run:function:start:local",
"scanner:rule:add",
"scanner:rule:describe",
"scanner:rule:list",
"scanner:rule:remove",
"scanner:run",
"scanner:run:dfa",
"whoami:functions",
"commands",
"help",
"plugins",
"plugins:inspect",
"plugins:install",
"plugins:add",
"plugins:link",
"plugins:uninstall",
"plugins:unlink",
"plugins:remove",
"plugins:update",
"update",
"telemetry",
"version",
"search",
"which",
"apex:get:log",
"force:apex:log:get",
"apex:get:test",
"force:apex:test:report",
"apex:list:log",
"force:apex:log:list",
"apex:run",
"force:apex:execute",
"apex:run:test",
"force:apex:test:run",
"apex:tail:log",
"force:apex:log:tail",
"org:list:auth",
"force:auth:list",
"auth:list",
"org:login:access-token",
"force:auth:accesstoken:store",
"auth:accesstoken:store",
"org:login:device",
"force:auth:device:login",
"auth:device:login",
"org:login:jwt",
"force:auth:jwt:grant",
"auth:jwt:grant",
"org:login:sfdx-url",
"force:auth:sfdxurl:store",
"auth:sfdxurl:store",
"org:login:web",
"force:auth:web:login",
"auth:web:login",
"org:logout",
"force:auth:logout",
"auth:logout",
"login",
"logout",
"data:create:record",
"force:data:record:create",
"data:delete:bulk",
"data:delete:record",
"force:data:record:delete",
"data:delete:resume",
"data:export:tree",
"force:data:tree:export",
"data:get:record",
"force:data:record:get",
"data:import:tree",
"force:data:tree:import",
"data:query",
"force:data:soql:query",
"data:query:resume",
"force:data:soql:bulk:report",
"data:resume",
"data:update:record",
"force:data:record:update",
"data:upsert:bulk",
"data:upsert:resume",
"force:data:bulk:delete",
"force:data:bulk:status",
"force:data:bulk:upsert",
"autocomplete",
"autocomplete:create",
"autocomplete:script",
"doctor",
"info:releasenotes:display",
"whatsnew",
"force:org:clone",
"force:org:create",
"force:org:delete",
"force:org:status",
"org:create:sandbox",
"env:create:sandbox",
"org:create:scratch",
"env:create:scratch",
"org:delete:sandbox",
"env:delete:sandbox",
"org:delete:scratch",
"env:delete:scratch",
"org:display",
"force:org:display",
"org:list",
"force:org:list",
"org:list:metadata",
"force:mdapi:listmetadata",
"org:list:metadata-types",
"force:mdapi:describemetadata",
"org:open",
"force:org:open",
"force:source:open",
"org:resume:sandbox",
"env:resume:sandbox",
"org:resume:scratch",
"env:resume:scratch",
"deploy",
"project:convert:mdapi",
"force:mdapi:convert",
"project:convert:source",
"force:source:convert",
"project:delete:source",
"force:source:delete",
"project:delete:tracking",
"force:source:tracking:clear",
"project:deploy:cancel",
"deploy:metadata:cancel",
"project:deploy:preview",
"deploy:metadata:preview",
"project:deploy:quick",
"deploy:metadata:quick",
"project:deploy:report",
"deploy:metadata:report",
"project:deploy:resume",
"deploy:metadata:resume",
"project:deploy:start",
"deploy:metadata",
"project:deploy:validate",
"deploy:metadata:validate",
"project:generate:manifest",
"force:source:manifest:create",
"project:list:ignored",
"force:source:ignored:list",
"project:reset:tracking",
"force:source:tracking:reset",
"project:retrieve:preview",
"retrieve:metadata:preview",
"project:retrieve:start",
"retrieve:metadata",
"sobject:describe",
"force:schema:sobject:describe",
"sobject:list",
"force:schema:sobject:list",
"limits:api:display",
"force:limits:api:display",
"org:list:limits",
"limits:recordcounts:display",
"force:limits:recordcounts:display",
"org:list:sobject:record-counts",
"schema:generate:field",
"generate:metadata:field",
"schema:generate:platformevent",
"generate:metadata:platformevent",
"schema:generate:sobject",
"generate:metadata:sobject",
"schema:generate:tab",
"generate:metadata:tab",
"alias:list",
"force:alias:list",
"alias:set",
"force:alias:set",
"alias:unset",
"force:alias:unset",
"config:get",
"force:config:get",
"config:list",
"force:config:list",
"config:set",
"force:config:set",
"config:unset",
"force:config:unset",
"plugins:trust:verify",
"force",
"force:mdapi:deploy",
"force:mdapi:deploy:cancel",
"force:mdapi:deploy:report",
"force:mdapi:retrieve",
"force:mdapi:retrieve:report",
"force:source:deploy",
"force:source:deploy:cancel",
"force:source:deploy:report",
"force:source:pull",
"force:source:push",
"force:source:retrieve",
"force:source:status",
"force:user:password:generate",
"force:user:permset:assign",
"force:user:permsetlicense:assign",
"org:assign:permset",
"org:assign:permsetlicense",
"org:create:user",
"force:user:create",
"org:display:user",
"force:user:display",
"org:generate:password",
"org:list:users",
"force:user:list",
"analytics:generate:template",
"force:analytics:template:create",
"apex:generate:class",
"force:apex:class:create",
"apex:generate:trigger",
"force:apex:trigger:create",
"lightning:generate:app",
"force:lightning:app:create",
"lightning:generate:component",
"force:lightning:component:create",
"lightning:generate:event",
"force:lightning:event:create",
"lightning:generate:interface",
"force:lightning:interface:create",
"lightning:generate:test",
"force:lightning:test:create",
"project:generate",
"force:project:create",
"static-resource:generate",
"force:staticresource:create",
"visualforce:generate:component",
"force:visualforce:component:create",
"visualforce:generate:page",
"force:visualforce:page:create"
],
"nodeEngine": ">=14.0.0"
},
"pluginSpecificData": {
"@salesforce/plugin-source": [
{
"targetOrgApiVersion": "58.0"
}
]
},
"diagnosticResults": [
{
"testName": "salesforcedx plugin not installed",
"status": "pass"
},
{
"testName": "no linked plugins",
"status": "pass"
},
{
"testName": "[@salesforce/plugin-source] sourceApiVersion matches apiVersion",
"status": "warn"
},
{
"testName": "using latest or latest-rc CLI version",
"status": "pass"
}
],
"suggestions": [
"Check https://github.com/forcedotcom/cli/issues for CLI issues posted by the community.",
"Check http://status.salesforce.com for general Salesforce availability and performance.",
"Neither sourceApiVersion nor apiVersion are defined. The commands that deploy and retrieve source use the max apiVersion of the target org in this case. The issue isn't a problem, as long as it's the behavior you actually want."
],
"logFilePaths": [
"/app/1693328165878-command-stdout.log",
"/app/1693328165878-command-debug.log"
],
"commandExitCode": 0,
"commandName": "sf force:org:list --all --dev-debug"
}/app #

Debug Information

Running the get test command above, I see the following:

...
sf:connection DEBUG request: {"method":"GET","url":"https://wexinc.my.salesforce.com/services/data/v58.0/tooling/query?q=SELECT%20PercentCovered%20FROM%20ApexOrgWideCoverage","headers":{"content-type":"application/json","user-agent":"sfdx toolbelt:"}} +3s
Error (1): Cannot read properties of null (reading 'replace')

*** Internal Diagnostic ***

TypeError: Cannot read properties of null (reading 'replace')
at JUnitReporter.xmlEscape (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/reporters/junitReporter.js:71:14)
at JUnitReporter.buildTestCases (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/reporters/junitReporter.js:53:37)
at JUnitReporter.format (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/reporters/junitReporter.js:27:24)
at TestService. (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/tests/testService.js:208:81)
at Generator.next ()
at /usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/tests/testService.js:8:71
at new Promise ()
at __awaiter (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/tests/testService.js:4:12)
at TestService.writeResultFiles (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/apex-node/lib/src/tests/testService.js:174:16)
at TestReporter.report (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-apex/lib/reporters/testReporter.js:34:31)


...

@github-actions
Copy link

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.

@github-actions
Copy link

Hello @Garnet-Merrill 👋 None of the versions of sf you shared match the latest release.

Shared: 2.2.7
Latest: 2.5.8

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

@Garnet-Merrill
Copy link
Author

{
"cliVersion": "@salesforce/cli/2.5.8",
"architecture": "linux-arm64",
"nodeVersion": "node-v20.5.0",
"osVersion": "Linux 5.15.49-linuxkit-pr",
"shell": "ash",
"rootPath": "/usr/local/lib/node_modules/@salesforce/cli",
"pluginVersions": [
"@oclif/plugin-autocomplete 2.3.6 (core)",
"@oclif/plugin-commands 2.2.22 (core)",
"@oclif/plugin-help 5.2.17 (core)",
"@oclif/plugin-not-found 2.3.37 (core)",
"@oclif/plugin-plugins 3.2.6 (core)",
"@oclif/plugin-search 0.0.22 (core)",
"@oclif/plugin-update 3.1.32 (core)",
"@oclif/plugin-version 1.3.8 (core)",
"@oclif/plugin-warn-if-update-available 2.0.48 (core)",
"@oclif/plugin-which 2.2.30 (core)",
"@salesforce/cli 2.5.8 (core)",
"apex 2.3.10 (core)",
"auth 2.8.12 (core)",
"data 2.5.6 (core)",
"deploy-retrieve 1.17.5 (core)",
"info 2.6.39 (core)",
"limits 2.3.30 (core)",
"login 1.2.26 (core)",
"org 2.10.0 (core)",
"schema 2.3.23 (core)",
"settings 1.4.25 (core)",
"sobject 0.2.4 (core)",
"source 2.10.31 (core)",
"telemetry 2.3.0 (core)",
"templates 55.5.10 (core)",
"trust 2.6.1 (core)",
"user 2.3.28 (core)"
]
}

@pogilvieCB
Copy link

I'm having a similar problem

sf package version list -v devhub
    TypeError: Cannot read properties of undefined (reading 'prototype')

@mshanemc mshanemc transferred this issue from forcedotcom/cli Sep 7, 2023
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

No branches or pull requests

2 participants