jackwener/OpenCLI · error · ConfigError

Invalid ${label}: ${raw}

Error message

Invalid ${label}: ${raw}

What it means

This ConfigError is thrown by normalizeBaseUrl() when the configured Atlassian base URL cannot be parsed by the URL constructor — it is not an absolute URL. Typically the value is missing the scheme (e.g. "example.atlassian.net" instead of "https://example.atlassian.net") or contains stray characters.

Source

Thrown at clis/_atlassian/shared.js:31

function firstEnv(names) {
    for (const name of names) {
        const value = process.env[name]?.trim();
        if (value) return value;
    }
    return '';
}

function normalizeBaseUrl(value, label) {
    const raw = String(value ?? '').trim();
    if (!raw) {
        throw new ConfigError(`Missing ${label}`, `Set ${label}, for example https://example.atlassian.net`);
    }
    let parsed;
    try {
        parsed = new URL(raw);
    } catch {
        throw new ConfigError(`Invalid ${label}: ${raw}`, 'Use an absolute http(s) URL.');
    }
    if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
        throw new ConfigError(`Invalid ${label}: ${raw}`, 'Use an http(s) URL.');
    }
    parsed.hash = '';
    parsed.search = '';
    return parsed.toString().replace(/\/+$/, '');
}

function parseDeployment(raw, baseUrl) {
    const value = String(raw || 'auto').trim().toLowerCase();
    if (!DEPLOYMENTS.has(value)) {
        throw new ConfigError('Invalid ATLASSIAN_DEPLOYMENT', 'Expected one of: cloud, datacenter, auto.');
    }
    if (value !== 'auto') return value;
    const host = new URL(baseUrl).hostname;
    return host === 'atlassian.net' || host.endsWith('.atlassian.net') ? 'cloud' : 'datacenter';
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Prefix the value with an explicit scheme: use https://example.atlassian.net, not example.atlassian.net
  2. Trim whitespace/quotes: set the env var cleanly (export ATLASSIAN_SITE='https://example.atlassian.net')
  3. Validate with `node -e "new URL(process.env.ATLASSIAN_SITE)"` before running the CLI

Example fix

// before
export ATLASSIAN_SITE="example.atlassian.net"   // Invalid: not absolute
// after
export ATLASSIAN_SITE="https://example.atlassian.net"
Defensive patterns

Strategy: validation

Validate before calling

function isAbsoluteHttpUrl(v) {
  try { const u = new URL(String(v).trim()); return u.protocol === 'https:' || u.protocol === 'http:'; }
  catch { return false; }
}
if (!isAbsoluteHttpUrl(process.env.ATLASSIAN_SITE)) throw new Error('ATLASSIAN_SITE must be an absolute http(s) URL');

Type guard

const isAbsoluteHttpUrl = (v) => {
  try { const u = new URL(v); return u.protocol === 'http:' || u.protocol === 'https:'; } catch { return false; }
};

Try / catch

try {
  return await cli.call('jira.search', { jql });
} catch (e) {
  if (e instanceof ConfigError && /^Invalid /.test(e.message)) {
    console.error('Base URL must be absolute, e.g. https://example.atlassian.net');
  }
  throw e;
}

Prevention

When it happens

Trigger: Setting the Atlassian base URL to a bare hostname like "example.atlassian.net", a value with quotes/spaces/newlines embedded, or a relative path like "/wiki".

Common situations: Copy-pasting the site name without https://, shell quoting issues leaving literal quotes in the env var, or confusing the site hostname with the full URL in docs.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/6e50b194450fd87f. Report an issue: GitHub.