SF CLI Community Create Fails After Winter '24 Update
Hey everyone, it looks like we've got a bit of a snag with the Salesforce CLI, specifically when trying to create communities. Since the Winter '24 update rolled out, the sf community create
command seems to be throwing a wrench in the works for a lot of us. Let's dive into what's happening, how to reproduce the issue, and what we can do about it.
The Problem: Community Creation Woes
So, here's the deal: ever since our dev hubs got the Winter '24 update (around October 6th), the sf community create
command has been failing. We run the command, and everything seems to go fine at first. The CLI gives us an ID, we query it, and boom – the status is "Error." The error message itself isn't super helpful, just saying, "An unexpected error occurred. Try again or contact your Salesforce administrator for help." Not exactly what you want to see after you've been working to automate your workflow.
What's really strange is that if we jump into the same scratch org and manually create the community with the exact same settings, it works like a charm. This points to a specific issue with the CLI command itself, rather than a general problem with the org setup or permissions. It's a classic case of "it works when I do it manually, but not when the computer does it."
The URL Path Prefix Mystery
There's also a little wrinkle in the documentation. The sf community create --help
command doesn't tell you that the --url-path-prefix
flag is now required. But, if you run the create command without the --url-path-prefix
flag, it'll fail. It's like the CLI is keeping a secret!
How to Reproduce the Issue
Alright, if you want to see this in action, here's how you can reproduce the issue, step by step. First, you will need a Salesforce org that has been updated to the Winter '24 release. If you don't have one, you can create a new scratch org and specify the Winter '24 release as the API version for the org in your sfdx-project.json. Then follow these steps:
-
Get a Project: Either generate a new project using
sf project generate
or use an existing project. If you don't have one, forking the dreamhouse-lwc project is a good option. It's a great starting point and has everything you need for testing. -
Spin Up a Scratch Org: Make sure your scratch org is running the Winter '24 update. You can specify the API version in your
sfdx-project.json
to ensure this. Then, authorize your org with your Salesforce CLI. -
Run the Create Command: Use the following command to try creating a community:
sf community create --name 'Broker Portal' --template-name 'Partner Central' --url-path-prefix BrokerPortal --json -o <org-alias>
Replace
<org-alias>
with the alias of your scratch org. -
Check the Status: After running the create command, grab the ID that it returns. Then, query the status using this command:
sf data query --query "SELECT fields(all) FROM BackgroundOperation WHERE Id = '<id-here>' LIMIT 200" --json -o <org-alias>
Replace
<id-here>
with the ID you got from the create command and<org-alias>
with your org alias. The output should display an "Error" status.
What Should Happen vs. What Actually Happens
The Expected Result
Ideally, when you run the sf community create
command, the site should be created successfully in your scratch org. You'd expect to see the community activated and ready to go, allowing you to start customizing and building out your portal or site.
The Actual Result
Instead of a shiny new community, you get an error. The background operations associated with the community creation fail, and you're left with a broken community. The error message provides little insight into the specific cause, making it difficult to troubleshoot.
Additional Info and System Setup
If you're experiencing this issue, it's useful to include as much detail as possible in your report. Provide your sf cli version, which shell or terminal you're using. You can get the full output of the sf version --verbose --json
command.
For context, the CLI version used during this problem report is:
$ sf --version
@salesforce/cli/2.108.6 darwin-arm64 node-v22.19.0
System Information
To help troubleshoot, it's good to know what's going on with your system. The more info we have, the easier it is to figure out what's causing the issue. Here's where you'd paste the output of the sf version --verbose --json
command:
PASTE_VERSION_OUTPUT_HERE
Make sure to include the shell or terminal you're using (e.g., bash, zsh, PowerShell).
Why This Matters
This bug is a real productivity killer. If you're using the CLI to automate your community creation, it basically stops you in your tracks. And since the manual creation method works, it also means the issue lies specifically within the command itself. The CLI is such a vital tool for Salesforce developers. So, when something like this pops up, it can be a frustrating experience. Here are a few reasons this problem is more than just a minor inconvenience.
- Automated Deployments: If you're using CI/CD pipelines or automated deployment scripts, this bug will break your build processes. Without being able to create communities via the CLI, you'll have to find alternative methods. This makes it difficult to deploy and manage communities at scale.
- Consistency: Manual processes are prone to human error. Using the CLI helps ensure that community creation is consistent across environments, which is essential for quality and ease of support.
- Time Savings: The CLI is a time-saver. You can use it to automate repetitive tasks and speed up your development workflow. Having to manually create communities defeats the purpose of this efficiency.
Wrapping Up
So, there you have it – the sf community create
command is experiencing some hiccups after the Winter '24 update. We've covered what's happening, how to replicate the issue, and why it's important to get it fixed. Let's hope the Salesforce team can get this sorted out soon so we can get back to creating communities with ease.
For more info about the Salesforce CLI and other Salesforce-related resources, check out the official Salesforce documentation. You can also look at the Salesforce Developers website.