Namespace not configured and exceptions logged for SFDX project with developer edition connection having a namespace

Issue #2239 resolved
René Görgens created an issue

Hi Scott,

When I configure a new SFDX project with a developer edition connection having a namespace, the namespace is not retrieved and exceptions are logged.

Details:

  • Create a new Illuminated Cloud SFDX Project project (generate manifest and OST). Click Create

    • Message: You may now choose an existing org, authorize a new org, or create a new scratch org for this project. Click OK
  • In the module config, select the module and click Add Connection

  • Authorise a new OAuth connection to a developer edition having a namespace

    • Message: Successfully authorized 'SMTest1' as '[redacted]'. Click OK
  • Confirm the Connections dialogue with OK

    • Message: Setting the connection for module 'Test_SFDX2' to 'SMTest1'. Click OK

  • Confirm the modules config with OK

    • Message: The offline symbol table will be generated for connection 'SMTest1'. Click OK
    • Message: It is recommended that you reload the project after rebuilding caches and indices. Reload project now? Click Yes
  • Check sfdx-project.json:

{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"name": "Test_SFDX2",
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "55.0"
}

See attached log for exceptions occuring during the first steps.

  • 2022-11-02 19:15:14,919 [4218419] INFO - #c.i.c.ForceComApiClient - Login successful for connection '[redacted] Developer Edition POC'.

    • => This is not the selected connection (!), but the first connection in the list
  • 2022-11-02 19:25:41,713 [4845213] INFO - #c.i.c.ForceComApiClient - Logging into Salesforce DX as [redacted].

    • => This is the selected connection

Comments (15)

  1. Scott Wells repo owner

    Does the selected connection show a namespace in the connection manager, e.g.:

    If not, click the Test button for that connection and see if it doesn’t pick it up. If it doesn’t, please run sfdx force:org:list --json and see whether the namespace is being properly reported by the CLI, e.g.:

          {
            "username": "<redacted>",
            "orgId": "<redacted>",
            ...
            "namespacePrefix": "base_dev",
            ...
          },
    

    If you don’t see the namespacePrefix property set properly in that output, that’s the core issue and you should do a scorched earth reinstall of the CLI as it’s evidencing an old issue that should be resolved. If you do, I’ll probably need to see some logs as to why that’s not getting conveyed into the connection.

  2. René Görgens reporter

    Thanks, the namespace was picked up when doing the Test!

    It is however not being added to sfdx-project.json.

    I don’t see the namespacePrefix in the output of sfdx force:org:list --json

    [Uninstalling SFDX…]

  3. Scott Wells repo owner

    IC2 will not update sfdx-project.json with the namespace. It actually doesn’t manipulate that file at all once the project has been created. The namespace in that file is primarily used during scratch org creation (unless you specify the no-namespace option) to cause the created scratch org to use the specified namespace, and then only if it’s associated with the dev hub. It’s not needed for development against an org that already has a namespace.

    Let me know if a reinstall doesn’t fix the issue with the namespace not showing up in the output of force:org:list.

  4. René Görgens reporter

    After a scorched earth reinstall of SFDX, the namespace was picked up during OAuth connection creation without needing Test. This looks much better:

    However the outpout of sfdx force:org:list --json | select-string -Pattern 'namespace' comes up empty/ the namespacePrefix is still not showing up in the output of sfdx force:org:list. Nor is it shown in sfdx force:org:display -u [redacted]. This is with sfdx-cli/7.174.0 win32-x64 node-v16.17.1.

    Potentially a regression of https://github.com/forcedotcom/cli/issues/1146 ? (https://github.com/forcedotcom/cli/issues/422)

  5. Scott Wells repo owner

    I’d be surprised if there were a regression. I’m not seeing it locally, nor have I heard about it from anyone else (and I was definitely hearing about it!). Rather than trying to grep the output of that command, I’d recommend you redirect it to a file, open that file, and find the actual entry with alias SMTest1 to see what it shows for namespacePrefix (if anything).

  6. René Görgens reporter

    Thanks, here’s the resulting file (with other connections removed and secrets redacted, but otherwise untouched):

    {
    "status": 0,
    "result": {
    "nonScratchOrgs": [
    {
    "accessToken": "[redacted]",
    "instanceUrl": "[redacted]",
    "orgId": "[redacted]",
    "username": "[redacted]",
    "loginUrl": "https://login.salesforce.com/",
    "clientId": "PlatformCLI",
    "isDevHub": false,
    "instanceApiVersion": "56.0",
    "instanceApiVersionLastRetrieved": "02/11/2022, 21:36:46",
    "alias": "SMTest1",
    "lastUsed": "2022-11-02T20:43:36.748Z",
    "connectedStatus": "Connected"
    }
    ],
    "scratchOrgs": []
    }
    }

  7. René Görgens reporter

    I did a scorched earth reinstall, including deleting .sf and .sfdx prior to installation. I subsequently re-registered the developer edition connection.

    • The namespace was picked up during OAuth connection creation without needing Test.
    • However the outpout of sfdx force:org:list --json is still missing a namespace parameter.

  8. Scott Wells repo owner

    That’s really strange. Does sfdx force:org:display -u <alias> --json show the correct namespace? If so (or likely even if not), you might log a case in the Salesforce CLI public issue tracker with the command-line reproduction of this to see what they have to say.

  9. Scott Wells repo owner

    Okay. I'll be curious to hear what they say. I'm going to resolve this since reinstalling the CLI (or something) took care of the project namespace issue in IC2.

  10. Log in to comment