fix(editor): Stop repeating the caller policy label when the project is unknown

Draft
RI
2mo ago
+30-15

Summary

The This workflow can be called by dropdown labels the same-owner option Only workflows in {projectName}. When the owning project is unknown, the project name falls back to the string Only workflows in the same project, which is a whole sentence rather than a name. Interpolating one into the other gives:

Only workflows in Only workflows in the same project

The owning project is unknown more often than it looks. loadWorkflowCallerPolicyOptions() builds the labels synchronously, and it sits in the same Promise.all as workflowsListStore.fetchWorkflow(workflowId), so it runs before that fetch resolves. Any time the workflow is not already in the list store cache, homeProject is still undefined when the label is built.

The fix uses the label that names no project when there is no name to interpolate, rather than passing a sentence in as the name.

The added test reproduces it against the existing fixture, which has no homeProject. It fails on master with:

- Only workflows in Only workflows
+ Only workflows in Only workflows in the same project

How to test

  1. Open a workflow's settings on an instance with the Sharing feature, having loaded the page directly rather than from the workflow list.
  2. Open the This workflow can be called by dropdown. The same-owner option reads Only workflows in the same project, not the doubled text.

Related Linear tickets, Github issues, and Community forum posts

Found while working on https://linear.app/n8n/issue/ADO-4923. Split out because it is a pre-existing bug with its own cause, reproducible on master.

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive.
  • Tests included.