usebruno/bruno · error · Error

A non-empty Git remote URL is required

Error message

A non-empty Git remote URL is required

What it means

`setCollectionGitRemote` validates that `remoteUrl` is a non-empty string before touching the workspace. It rejects null, non-strings, and whitespace-only values outright.

Source

Thrown at packages/bruno-electron/src/utils/workspace-config.js:445

  const hasManagedEntries = filteredManagedLines.some((line) => line.trim() !== '');
  const filtered = hasManagedEntries
    ? [
        ...lines.slice(0, managedBlock.start + 1),
        ...filteredManagedLines,
        ...lines.slice(managedBlock.end)
      ]
    : [
        ...lines.slice(0, managedBlock.start),
        ...lines.slice(managedBlock.end + 1)
      ];

  await writeFile(gitignorePath, filtered.join('\n'));
};

const setCollectionGitRemote = async (workspacePath, collectionPath, remoteUrl) => {
  if (typeof remoteUrl !== 'string' || remoteUrl.trim() === '') {
    throw new Error('A non-empty Git remote URL is required');
  }
  const trimmedUrl = remoteUrl.trim();

  return withLock(getWorkspaceLockKey(workspacePath), async () => {
    const config = readWorkspaceConfig(workspacePath);
    const target = path.normalize(collectionPath);
    let matched = false;

    config.collections = (config.collections || []).map((c) => {
      if (getNormalizedAbsoluteCollectionPath(workspacePath, c) !== target) return c;
      matched = true;
      return { ...c, remote: trimmedUrl };
    });

    if (!matched) {
      throw new Error('Collection not found in workspace');
    }

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Pass a non-empty git URL string (e.g. `https://github.com/org/repo.git`).
  2. Trim and validate the URL in the form/controller before calling.
  3. If the intent is to clear the remote, call `clearCollectionGitRemote` instead.

Example fix

// before
await setCollectionGitRemote(wsPath, colPath, '');

// after
await setCollectionGitRemote(wsPath, colPath, 'https://github.com/org/repo.git');
Defensive patterns

Strategy: validation

Validate before calling

function assertRemoteUrl(url) {
  if (typeof url !== 'string' || url.trim() === '') {
    throw new Error('A non-empty Git remote URL is required');
  }
  return url.trim();
}

Type guard

function isNonEmptyRemoteUrl(url: unknown): url is string {
  return typeof url === 'string' && url.trim().length > 0;
}

Prevention

When it happens

Trigger: Calling `setCollectionGitRemote(workspacePath, collectionPath, remoteUrl)` with `remoteUrl` undefined, not a string, or empty/whitespace after `trim()`.

Common situations: A 'set remote' form submitted blank; a caller passed the whole git config object instead of the URL field; clipboard paste of an empty cell; a refactor that swapped argument order.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/83413e56639843ab. Report an issue: GitHub.