Mintplex-Labs/anything-llm · error

Scheme not supported: ${connectionStringObject.scheme}

Error message

Scheme not supported: ${connectionStringObject.scheme}

What it means

Thrown by ConnectionStringParser.format when the parser was constructed with a fixed scheme (e.g. 'mysql' or 'postgresql') but the connection-string object passed in carries a different non-empty scheme. format() serializes an object back into a URI and refuses to emit a scheme it was not built for, rather than silently producing a cross-engine connection string.

Source

Thrown at server/utils/agents/aibitat/plugins/sql-agent/SQLConnectors/utils.js:43

      (options && options.scheme) || ConnectionStringParser.DEFAULT_SCHEME;
  }

  /**
   * Takes a connection string object and returns a URI string of the form:
   *
   * scheme://[username[:password]@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[endpoint]][?options]
   * @param {Object} connectionStringObject The object that describes connection string parameters
   */
  format(connectionStringObject) {
    if (!connectionStringObject) {
      return this.scheme + "://localhost";
    }
    if (
      this.scheme &&
      connectionStringObject.scheme &&
      this.scheme !== connectionStringObject.scheme
    ) {
      throw new Error(`Scheme not supported: ${connectionStringObject.scheme}`);
    }

    let uri =
      (this.scheme ||
        connectionStringObject.scheme ||
        ConnectionStringParser.DEFAULT_SCHEME) + "://";

    if (connectionStringObject.username) {
      uri += encodeURIComponent(connectionStringObject.username);
      // Allow empty passwords
      if (connectionStringObject.password) {
        uri += ":" + encodeURIComponent(connectionStringObject.password);
      }
      uri += "@";
    }
    uri += this._formatAddress(connectionStringObject);
    // Only put a slash when there is an endpoint
    if (connectionStringObject.endpoint) {

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Make the object's scheme match the parser's scheme exactly, or omit scheme from the object so the parser's own scheme is used.
  2. If the object genuinely belongs to another engine, use a parser constructed with that engine's scheme.
  3. Normalize aliases before formatting: 'postgres'->'postgresql', 'mssql'/'sqlserver'->'sql-server' per the connector in use.

Example fix

// before
const parser = new ConnectionStringParser({ scheme: "mysql" });
parser.format({ scheme: "postgresql", hosts: [...] });  // throws

// after
parser.format({ hosts: [...] });  // parser's own scheme 'mysql' is used
Defensive patterns

Strategy: validation

Validate before calling

function formatSafely(parser, obj) {
  const o = { ...obj };
  if (o.scheme && o.scheme !== parser.scheme) {
    delete o.scheme; // let the parser's own scheme win, or reject explicitly:
    // throw new Error(`scheme '${o.scheme}' does not match connector '${parser.scheme}'`);
  }
  return parser.format(o);
}

Type guard

/** @returns {boolean} */
function schemeMatches(parser, obj) {
  return !obj?.scheme || !parser?.scheme || parser.scheme === obj.scheme;
}

Try / catch

try {
  const uri = parser.format(connectionStringObject);
} catch (e) {
  if (e.message.startsWith("Scheme not supported:")) {
    // either drop obj.scheme or route the object to a parser built for that scheme
  } else throw e;
}

Prevention

When it happens

Trigger: Constructing a parser for one engine (new ConnectionStringParser({ scheme: 'mysql' })) and calling format({ scheme: 'postgres', ... }); mixing a parsed PostgreSQL URI's object into a MySQL formatter; stored config edited so scheme no longer matches the connector that formats it.

Common situations: Copy-pasting connection objects between connector configs when switching databases; scheme aliases ('postgres' vs 'postgresql') passed through from user input into format().

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/4091c63e9bac5e33. Report an issue: GitHub.