Query scratch org to determine namespace

Issue #1967 resolved
Reede Stockton created an issue

IC currently relies on sfdx-project.json to establish the namespace for scratch orgs in module configuration. Our team develops against a repository that includes sfdx-project.json with a namespace value that is used to spin up orgs with a tool that is external to IC. Our development model, however, requires us to use non-namespaced orgs for development. That produces a mismatch between the namespaced org that IC expects and the connected non-namespaced org, resulting in errors with symbol resolution and test execution.

If IC could query the actual scratch org to determine the namespace, that would resolve our issue.

Comments (5)

  1. Scott Wells repo owner

    I've hit one snag implementing this. I just filed a bug against the CLI for an issue where scratch org namespaces are not accurately/consistently reported by force:org:list which is what IC2 uses to get summary-level information about CLI-managed orgs:

    https://github.com/forcedotcom/cli/issues/1146

    That would actually ensure that IC2 is aware of the scratch org namespaces, especially where your scratch orgs are created by CumulusCI (correct?) and not explicitly by the developer.

    There are plenty of workarounds I could implement in IC2, but after chatting with the folks on the CLI team, hopefully this can be fixed and included in a CLI update quite quickly. I'd certainly prefer to do this the right way rather than introduce a workaround into IC2.

    I may still be able to provide some type of early access to this feature even before such a fix is produced. It would likely require the developer to explicitly use the Test button on the scratch org connection to force IC2 to pick up the org's namespace and use it. But once the fix for this CLI issue is provided, that shouldn't ever be necessary for IC2 to know about the namespaces for scratch orgs. I'll keep you posted here...

  2. Reede Stockton reporter

    You’re correct. Our scratch orgs are being created by CumulusCI.

    Not sure about the workaround for early access. We’ve experienced the namespace flipping back to the value in sfdx-project.json if that value ever changes, as it might with a pull. If the early access workaround is persistent under those circumstances, it would solve a lot of our headaches.

  3. Scott Wells repo owner

    Okay, here's a build that should do what you're wanting. These changes won't go into the official build until the linked CLI issue with scratch org namespace reporting is fixed, but until that happens I'm happy to provide an unofficial version of the latest official build here with these changes.

    Download the attached archive, but don't extract it. Install it using Settings / Preferences > Plugins > Install plugin from disk (under the gear drop-down menu). Allow the IDE to restart, and you should be good to go.

    Basically with these changes, IC2 uses the org-reported namespace exclusively and never the one from sfdx-project.json. Because you're using orgs without namespaces, it should just work immediately. If you were using orgs with namespaces you might need to go into the project's scratch org connection and click the Test button so that IC2 explicitly queries the org for its namespace. Once the CLI issue is fixed that shouldn't ever be necessary, though.

    Please let me know whether this resolves the remaining issues you've been having or not. If you do have issues, you can revert to the official build by uninstalling the plugin and reinstalling the latest released build from the plugin repository.

  4. Scott Wells repo owner

    The CLI fix to include the namespace properly in force:org:list has been committed and should be in the next CLI release (typically on Thursday, but that's not under my control). Once that's done AND I have a chance to verify the behavior, I'll look at getting the changes in the attached build into the official build.

  5. Log in to comment